Hi,
Have some questions re the use of SQL scripting under Server | SQL Databases \ Database server | Predefined Connection | SQL script | New SQL Script File.
Use of Statement separator.
I really do not understand the statement " during installation the QQL script file will be automatically split into component statements using the supplied statement separator and each SQL statement will be executed individually. Otherwise the SQL script will be executed as a whole."
I have a script that is something like:
Declare @variable bit
Set @variable = 1;
If (db exists) -- do this since could be updating over an existing sql db and need to store customer data somewhere
begin
run a bat file using bcp -- this exports rows in tables to dat file
drop database
set @variable = 0
end
if (db not exists) --which it won't of course but could be and initial install
begin
restore db --this is an updated data base
end
--do some other sql stuff!!!
if @variable = 0 --means have customer data so need to import into
begin
run a bat file using bcp that imports created dat file above
end
No matter what I set statement separator to or update the script to include GO statements after each SQL command the log file only shows that the first "if (db exists)" statement is executed and anything after that is ignored.
I could break each statement into separate SQL scripts but not sure how to do the last step which is based on a variable updated in step one.
Thanks,
Brian