Wednesday, March 21, 2012

joining text in SP in SQL SERVER

here is my code:

declare @.strSQL nvarchar(4000);

set @.strSQL = 'select emailAddress from tblMailingList where mailingID > 0 ' ;
--send Mail
if len(@.sendMail)>0
@.strSQL+=' and sendMail =@.sendMail'

but I got this error:

Incorrect syntax near '@.strSQL'.

how can I joining the @.strSQL if the "if statement" is true?

thanks!

24sharon:


@.strSQL+=' and sendMail =@.sendMail'

Try this instead:

set @.strSQL = @.strSQL + ' and sendMail = ''' + @.sendMail + ''''

Hope this will help.

|||

at last line u have some wrong code. replace last line using -->


Set @.strSQL = @.strSQL + ' and sendMail = ''' + @.sendMail + ''''

No comments:

Post a Comment