I have this script I am trying to run, its quite simple. It works fine with one small problem. I have the script below
USE [Master]
DECLARE @spid smallint,
@SQLString varchar(50),
@cmd nvarchar(4000),
@data_path nvarchar(256)
-- retrieve data path based on location of master database
SET @data_path = (SELECT SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1) FROM master.sys.master_files WHERE database_id = 1 AND file_id = 1);
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'xxxxTools')
BEGIN
DECLARE ffcursor CURSOR FAST_FORWARD FOR
select es.session_id from sys.dm_exec_sessions es join sysprocesses sp on (es.session_id = sp.spid)
where db_name(sp.dbid) = 'xxxxTools'
OPEN ffcursor
FETCH NEXT FROM ffcursor
INTO @spid
WHILE @@FETCH_STATUS = 0
BEGIN
set @SQLString = 'KILL ' + cast(@spid as varchar(5))
exec(@SQLString)
FETCH NEXT FROM ffcursor
INTO @spid
END
CLOSE ffcursor
DEALLOCATE ffcursor
RESTORE DATABASE [xxxxTools] FROM DISK = '$supportdir$xxxxtoolsdb' WITH FILE = 1, NOUNLOAD, REPLACE
END
ELSE
BEGIN
DECLARE @log_path nvarchar(256)
set @log_path = @data_path + 'xxxxTools_Log.LDF'
set @data_path = @data_path + 'xxxxTools_Data.MDF'
RESTORE DATABASE xxxxTools
FROM DISK ='$supportdir$xxxxtoolsdb'
WITH MOVE 'xxxxTools_Data' TO @data_path,
MOVE 'xxxxTools_Log' TO @log_path
END
Now you will see the From Disk section has $supportdir$xxxxtoolsdb
I have the xxxxtoolsdb in the creatives dir
Now if I replace the $supportdir$ with a hard coded path it works.
ex C:/programfiles/xxxxtools/xxxxtoolsdb
Does anybody have any ideas why its not working with $supportdir$ in it?
Steven
SQL script works (but not with varabiles)
-
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
Did you try as $SUPPORTDIR$?
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
Who is online
Users browsing this forum: No registered users and 107 guests