EXECUTE @SQL

USE Northwind
GO

DECLARE @SQL NVARCHAR(1000) --要求 NVARCHAR 类型
SET @SQL = 'SELECT * FROM dbo.Customers'
EXECUTE sp_executesql @SQL
GO

USE Northwind
GO

DECLARE @SQL VARCHAR(1000)
SET @SQL = 'SELECT * FROM dbo.Customers'
EXECUTE (@SQL)
GO

你可能感兴趣的:(execute)