Link to home
Start Free TrialLog in
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

asked on

Need help with Query

Hi Experts,

I am trying to execute the following SQL
SET @SQL='Select * from CUSTEVENT where  CustEvntOpenOrClose="O"'

But I am getting error "Invalid column name 'O'." What am I doing wrong.
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use two single-quote marks instead of a double-quote mark
Declare @sql nvarchar(100) 

SET @SQL='Select * from CUSTEVENT where  CustEvntOpenOrClose=''O''' 

SELECT @sql

Open in new window

Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

ASKER

Thank you so much.
SET @q =  'Select * from tab where  col2=''O'''

Open in new window

difference is in quotes, all should be single quotes