October 7, 2003 at 11:46 am
Not that I know of. Typically on the app side you avoid this by changing the connection string or executing a use db on the open connection. One way might to put placeholders in your script, then at run time replace ~DBNAME1~ with the real name.
Andy
October 7, 2003 at 11:56 am
USE master
declare @dttm varchar(55)
select @dttm=convert(varchar,getdate(),113)
raiserror('Beginning InstPubs.SQL at %s ....',1,1,@dttm) with nowait
GO
if not exists (select * from sysdatabases where name='pubs')
begin
raiserror('Creating pubs database....',0,1)
CREATE DATABASE pubs ON DEFAULT = 3
end
GO
CHECKPOINT
go
USE pubs
--perform operation
go
use master
--perform operation
go
use yourdatabase
--perform operation
go
October 10, 2003 at 1:32 am
As long as you put 'GO' between creating the database and 'USE'ing it the script will run but I suspect you already knew that 🙂
I don't think there is anyway round getting the script to pass a syntax check and this may look a little knaff to your customers if they are running from it from isql or the like.
Viewing 3 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply