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 |
|
tariq2
Posting Yak Master
125 Posts |
Posted - 2011-03-07 : 13:21:22
|
| Hi, Thanks in advance for your assistanceThe following does not quite work:CREATE PROCEDURE ti_symprodF0902@jn char(12),@lt char(2),@fy char(2)ASselect * from openquery(symprod_etldev,'select * from proddta.f0902 where gbmcu = '+@jn+' and gblt = '+@lt+' and gbfy = '+@fy+' ') When run, It yields the following message:Msg 102, Level 15, State 1, Procedure ti_symprodF0902, Line 7Incorrect syntax near '+'.There is a squiggly red line under @jn |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-03-07 : 13:28:42
|
| You have to make sure everything gets quoted properly. Compare the difference that you string produced to mine. 'select * from proddta.f0902 where gbmcu = ''' +@jn+ ''' and gblt = '''+@lt+''' and gbfy = '''+@fy+''' 'JimEveryday I learn something that somebody else already knew |
 |
|
|
tariq2
Posting Yak Master
125 Posts |
Posted - 2011-03-11 : 05:51:31
|
| fantastic, tahnkyou Jimf |
 |
|
|
|
|
|