| Author |
Topic  |
|
|
yaaadman
Starting Member
4 Posts |
Posted - 06/27/2007 : 10:09:18
|
I can't get the below dynamic sql to work. I am getting this error. Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near '.'. Any Help?
DECLARE @Sql nvarchar(2000)
SET @Sql = 'SELECT stag.id, REPLACE(stag.broker,stag.broker,''Staging'' + stag.broker ) ' SET @Sql = @Sql + 'us.cocoid, ua.UserAccountID ' SET @Sql = @Sql + '(CASE WHEN UPPER(BuySell) = ''SELL'' THEN 0 ELSE 1 END) ' SET @Sql = @Sql + 'stag.tradeDate, CONVERT(INT, REPLACE(stag.quantity,''.000'','''')) ' SET @Sql = @Sql + 'stag.symbol ' SET @Sql = @Sql + 'FROM dbo.StagingSchwab stag, Users us, UserAccounts ua ' SET @Sql = @Sql + 'WHERE stag.cusip <> '''' AND us.cocoid = ua.cocoid ' SET @Sql = @Sql + 'AND REPLACE(ua.AccountNumber,''-'','''') = stag.AccountNumber' |
|
|
harsh_athalye
Flowing Fount of Yak Knowledge
India
5509 Posts |
Posted - 06/27/2007 : 10:17:25
|
You are missing commas at the end of each concatenation, Dude!
SET @Sql = 'SELECT stag.id, REPLACE(stag.broker,stag.broker,''Staging'' + stag.broker ), ' SET @Sql = @Sql + 'us.cocoid, ua.UserAccountID, ' SET @Sql = @Sql + '(CASE WHEN UPPER(BuySell) = ''SELL'' THEN 0 ELSE 1 END), ' SET @Sql = @Sql + 'stag.tradeDate, CONVERT(INT, REPLACE(stag.quantity,''.000'','''')), ' SET @Sql = @Sql + 'stag.symbol ' SET @Sql = @Sql + 'FROM dbo.StagingSchwab stag, Users us, UserAccounts ua ' SET @Sql = @Sql + 'WHERE stag.cusip <> '''' AND us.cocoid = ua.cocoid ' SET @Sql = @Sql + 'AND REPLACE(ua.AccountNumber,''-'','''') = stag.AccountNumber'
Harsh Athalye India. "The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22460 Posts |
|
|
yaaadman
Starting Member
4 Posts |
Posted - 06/27/2007 : 11:27:16
|
| Thanks a bunch for all your help... It was really the missing commas |
 |
|
| |
Topic  |
|
|
|