SQLServer中获取当前数据库名称

(1):Select Name From Master..SysDataBases Where DbId=(Select Dbid From Master..SysProcesses Where Spid = @@spid)

(2):--NoteMessage 为数据库名称
if db_id('NoteMessage')=(Select Dbid From Master..SysProcesses Where Spid = @@spid)
print 'OK'

posted on 2008-11-16 01:53  一路前行  阅读(3521)  评论(3编辑  收藏  举报