我使用过这个sql,但它不能正常工作
SELECT @objname= OBJECT_DEFINITION (OBJECT_ID(N''+@fromDatabase+'..'+@spName))
print @objname
SET @objname = REPLACE(@objname,'''','''''')
SET @objname = 'USE ['+@toDatabase+']; GO EXEC(''' + @objname + ''')'
EXEC(@objname)
此处OBJECT_DEFINITION (OBJECT_ID('myprocedure'))
此功能与
SELECT [definition] FROM sys.sql_modules WHERE object_id = OBJECT_ID('MyProcedure')
但我需要像
这样的东西SELECT [definition] FROM **@from_db**.sys.sql_modules WHERE object_id = OBJECT_ID('MyProcedure')