alter statement in sybase

I wrote some SYbase sql to check if a column exists. If it does not exists I create a new column in the table. It almost works but something is wrong with my exec statement at line 3. When I try and run the code code block below I get an error message --> stored procedure '"ALTER TABLE dbo.customers ADD CustLoyalty VARCHAR(20)"' not found.
 So can someone tell me what is wrong at line 3 below?


1  if not exists (select 1 from syscolumns where id= object_id('dbo.customers') and name = 'CustLoyalty')
2   begin
3  exec "ALTER TABLE dbo.customers ADD CustLoyalty VARCHAR(20)"
4  end
LVL 2
brgdotnetcontractorAsked:
Who is Participating?
 
wilcoxonConnect With a Mentor Commented:
It looks like exec is looking for the name of a stored procedure.  Have you tried running it without the exec and quotes and just using alter table directly?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.