弱弱的一问,存储过程中可以执行拼接的SQL语句并返回结果吗?
CREATE PROCEDURE xx
AS
declare @main nvarchar(1000),
@where nvarchar(100),
@x int
select @where = "1=1"
select @main = "select top 1 ID from YQGL_DWYQ where " + @where
--select @x = execute sp_executesql @main <------这里
GO
如果这样不可以实现,有好的实现的方法吗?(除了游标)