我想在存储过程中创建包含此变量的SQL变量表;
Select a,b,c,d from **@tablename** where a=1 and c=0
创建sp?
时如何使用sp执行此操作答案 0 :(得分:5)
您可以在SP中将表变量声明为:
DECLARE @tablename TABLE(
a INT,
b INT,
c INT,
d INT);
SELECT * FROM @tablename;
答案 1 :(得分:0)
我希望这个答案对您有帮助
GO
CREATE PROCEDURE PrededureName
AS
BEGIN
DECLARE @tempTable TABLE
(
a INT,
b INT,
c INT,
d INT
)
INSERT INTO @tempTable (a, b, c, d)
SELECT a, b, c, d FROM @tablename WHERE a=1 and c=0
END
GO;