Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 SQL 中做类似的事情?
DECLARE @t Nvarchar(50) SET @t = 'SELECT * FROM KIN_PHON' execute @t --??
使用exec:
exec
DECLARE @t Nvarchar(50) SET @t = 'SELECT * FROM KIN_PHON' exec (@t)
或使用参数sp_executesql:
sp_executesql
declare @sql nvarchar(max) set @sql = 'select * from YourTable where ID = @ID' execute sp_executesql @sql, N'@ID int', @ID = 42;