Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic String for Cursor

Status
Not open for further replies.

Mdavis123

Programmer
Nov 12, 2001
56
US
Trying to build a rather large SQL statement dynamically.
How do you embedd the data with single quotes whithin a string. Thanks
Here is a snip..

Declare @Sql varchar(100)
Declare @Monday char(1)
Set @Monday='T'
Set @SQL='Declare Csr as Cursor For Select * from ABC'

***@Monday needs quotes
Set @sWhere2=@sWhere2+' Monday='+@Monday
Set @SQL=@SQL + ' Where ' +@sWhere + @sWhere2

 
Hi,

Try this out.

Declare @Sql varchar(100)
Declare @Monday char(1)
Set @Monday='T'
Set @SQL='Declare Csr as Cursor For Select * from ABC'

***@Monday needs quotes
Set @sWhere2=@sWhere2+' Monday='''+@Monday + '''
Set @SQL=@SQL + ' Where ' +@sWhere + @sWhere2


Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top