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 - 2002-04-23 : 09:05:58
|
| John Niemiec writes "Can I build a variable and then use that variable on the SET statement in the UPDATE portion of this query? That seems to be the issue, bu is there a work around.DECLARE @COUNTER INTEGERDECLARE @SETSTRING_1 CHAR(30) SET @COUNTER = 1SET @SETSTRING_1 = '#BILLING.M' + (CONVERT(CHAR(2),@COUNTER)) + '= #TEMP2.CHARGE' UPDATE #BILLINGSET @SETSTRING_1FROM #BILLING, #TEMP1WHERE (#BILLING + '.' + 'CLIENT') = (#TEMP1 + '.' + 'CLIENT') AND (#TEMP1 + '.' + 'MONTH') = ('M' + (CONVERT(CHAR(2),@COUNTER)))" |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-04-23 : 09:12:24
|
| Naw. You can't do that. Either explicitly type out all of your update statement, or dynamically build the entire statement into a varchar and exec(@mySQLStatement). If you go with the latter, you will probably have trouble with scope with your temp tables.<O> |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-04-23 : 09:14:20
|
Read these Articles on Dynamic Sql by our Merkin(Yak Dynamo) http://www.sqlteam.com/item.asp?ItemID=4599http://www.sqlteam.com/item.asp?ItemID=4619-------------------------------------------------------------- |
 |
|
|
|
|
|