Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
svicky9
Posting Yak Master
232 Posts |
Posted - 2007-05-05 : 16:08:08
|
| Hi Friends i am trying to create dynamic strings in Sql 2005Eg:declare @sql nvarchar(1000)set @sql=''set @sql= @sql+'select customername from customers'print @sql---The Above Example Prints the Statement--NowEg :2declare @string nvarchar(200)declare @sql nvarchar(1000)declare @c_id nvarchar(1000)declare @tablename varchar(100)declare @sstring varchar(100)set @c_id = 'customerid'set @tablename ='customers'set @sstring ='alfki'set @sql=@sql+'insert into sql_search select ['+@c_id+'] from '+@tablename+' where ['+@c_id+'] like '+@sstringprint @sql--The Above Eg 2 does not printIs it something to do with string concatenation???cheersVic |
|
|
svicky9
Posting Yak Master
232 Posts |
Posted - 2007-05-05 : 16:15:20
|
| thanks friends...figured it out...just setting @sql =''Vic |
 |
|
|
|
|
|