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
 stored procedure

Author  Topic 

Msandlana
Starting Member

33 Posts

Posted - 2008-01-21 : 06:33:38
I want to get the records on person table by emailaddress but there is a problem with this statement It works only when I select all the value. Its shows this error "Unclosed quotation mark after the character string ''."

If (@varEmailAddress <> '')
Begin
Set @varSelectSql = @varSelectSql + ' And A.EmailAddress like ' + '%' + cast(@varEmailAddress as varchar(100))+ '%'''
End

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-21 : 06:37:05
[code]IF COALESCE(@varEmailAddress, '') > ''
SET @varSelectSql = @varSelectSql + ' AND a.EmailAddress LIKE ''%' + @varEmailAddress + '%'''[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Msandlana
Starting Member

33 Posts

Posted - 2008-01-21 : 07:20:23
Thank you
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-21 : 08:34:37
Apply this logic
www.sommarskog.se/dyna-search.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -