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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query

Author  Topic 

tariq2
Posting Yak Master

125 Posts

Posted - 2011-03-07 : 13:21:22
Hi, Thanks in advance for your assistance
The following does not quite work:

CREATE PROCEDURE ti_symprodF0902
@jn char(12),
@lt char(2),
@fy char(2)

AS
select * 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 7
Incorrect 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+''' '

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

tariq2
Posting Yak Master

125 Posts

Posted - 2011-03-11 : 05:51:31
fantastic, tahnkyou Jimf
Go to Top of Page
   

- Advertisement -