我有这个
@mutation
@name
我要做的是让@mutation
查找产品名称(name.products
),然后@name
取@mutation
中产品的名称作为文本。所以我要做的是在产品表中获取产品的名称,并在以后使用它来命名视图。
ALTER PROCEDURE [dbo].[exec_view]
AS
BEGIN
DECLARE @mutation NVARCHAR(255);
DECLARE @name NVARCHAR(255) ;
SET @mutation = N'SELECT
name
FROM INSERTED
' ;
SET @test = N'@mutatation varchar' ;
EXECUTE sp_executesql @name = @mutation ;
EXEC (
'
CREATE VIEW @name
AS SELECT *
FROM view_for_future_mutation
');
END
答案 0 :(得分:0)
declare @name sysname;
set @name = (select quotename(name) from inserted);
exec (N'create view ' + @name + N' as select * from view_for_future_mutation');