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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-07-11 : 11:18:49
|
| Ishita writes "set @sqlString2 = 'update '+@tableName +' set ' + @GRP_nm + ' = '+@stringCat +' where ' + @Racf_id + ' = ''' + @currGrp_nm + '''' --exec(@sqlString2)I am trying to execute above string and it is not working.everyfield is varchar. please help" |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-07-11 : 11:23:44
|
| Try printing the string rather than executing it.maybeset @sqlString2 = 'update '+@tableName +' set ' + @GRP_nm + ' = '''+@stringCat +''' where ' + @Racf_id + ' = ''' + @currGrp_nm + ''''==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-07-11 : 11:24:08
|
If you run this instead, does the sql string look the way you want? If you run it, do you get an error? If so, what is it?set @sqlString2 = 'update '+@tableName +' set ' + @GRP_nm + ' = '+@stringCat +' where ' + @Racf_id + ' = ''' + @currGrp_nm + ''''print @sqlString2 Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-11 : 11:24:19
|
[code]set @sqlString2 = 'update '+@tableName +' set ' + @GRP_nm + ' = '''+@stringCat +''' where ' + @Racf_id + ' = ''' + @currGrp_nm + ''''[/code] KH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-11 : 11:27:11
|
Double  KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-07-12 : 02:51:44
|
| http://www.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|