在继续脚本之前,是否有办法获得验证脚本?
所以
DECLARE @strServernameToClear as VarChar(100)
DECLARE @strCurrentServer as VarChar(100)
DECLARE @strDatabaseToClear as VarChar (100)
DECLARE @strDatabase as VarChar (100)
SET @strDatabase = (SELECT @@database) << THIS IS WHERE IM HAVING TROUBLE. How to indicate which database it is running against
IF @strCurrentServer <> @strServernameToClear
BEGIN
PRINT '*****************WARNING *****************'
PRINT 'WRONG DB NAME: This server is: ' + @strCurrentServer
PRINT 'If this is the correct server, set @strServernameToClear to ' + @strCurrentServer
RETURN
END
ELSE
EXECUTE ORDER 66
答案 0 :(得分:0)
我认为这会为你效劳:
select @strDatabase = d.name
from sys.sysprocesses p
join sys.databases d on d.database_id = p.dbid
where p.spid = @@SPID