brgdotnet
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''
')
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.