淡泊明志 宁静致远
宠辱不惊 闲看庭前花开花落 去留无意 漫随天外云卷云舒
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[temp_GetDatabaseName]') AND type in (N'U'))
    drop table temp_GetDatabaseName
create Table temp_GetDatabaseName (
spid int,
ecid int,
status nvarchar(100),
loginame nvarchar(100),
hostName nvarchar(255),
blk int,
dbname nvarchar(255),
cmd nvarchar(1000),
request_id int --此字段在SQL 2000 中不存在,只存在于SQL2005
)
declare @dataBaseName nvarchar(128)
insert into temp_GetDatabaseName exec sp_who @@spid
select @dataBasename = dbName from temp_GetDatabaseName
print @dataBasename
posted on 2008-10-06 17:39  RainWaterLily  阅读(839)  评论(0编辑  收藏  举报