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 |
|
tchinedu
Yak Posting Veteran
71 Posts |
Posted - 2005-11-17 : 16:41:25
|
| I am trying to create a dynamic query, guys, what am I doing wrong. I tried to run the query below in query analyser and I can'tdeclare @SQL varchar(2000)declare @GroupNumber intdeclare @inputSQL varchar(200)set @inputSQL = 'CurrentBalance < 5464563456 OR Borrower1 < 600 'set @GroupNumber = 1select @SQL = ' update TempTable set GroupId = ' + @GroupNumber + ' where ' + @inputSQLExecute (@sql)Error Recieved from App.==========================Server: Msg 245, Level 16, State 1, Line 8Syntax error converting the varchar value ' update TempTable set GroupId = ' to a column of data type int. |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-11-17 : 18:23:06
|
You just need to change that line to convert the int to varchar.select @SQL = ' update TempTable set GroupId = ' + convert(varchar(20),@GroupNumber) + ' where ' + @inputSQL CODO ERGO SUM |
 |
|
|
|
|
|