Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

Rewriting a simple query

I am debugging some sql server code. See the "Before" code below. It will not run because of the UPDATE statement in the exec statement. So I changed the code to have an extra EXEC statement, with the Update statement by itself. See code marked "After "

Is there a better way that I can rewrite the "After" code, which works?



Before :

exec
('
  ALTER TABLE Customer ADD PROFILE_ID VARCHAR(100) null
  ALTER TABLE Customer ADD HIST_ID VARCHAR(100) null

  UPDATE Customer SET PROFILE_ID =' 'NEW'', HIST_ID = ''DEFAULT''
')

After:

exec
('
  ALTER TABLE Customer ADD PROFILE_ID VARCHAR(100) null
  ALTER TABLE Customer ADD HIST_ID VARCHAR(100) null
')

EXEC ('
  UPDATE Customer SET PROFILE_ID =''NEW'', HIST_ID = ''DEFAULT''
')
SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia 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
ASKER CERTIFIED SOLUTION
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