我想在存储过程中创建一个包含以下内容的SQL变量表:
Select a,b,c,d from **@tablename** where a=1 and c=0
在创建存储过程时,如何使用sp进行操作?
我想在存储过程中创建一个包含以下内容的SQL变量表:
Select a,b,c,d from **@tablename** where a=1 and c=0
您可以在存储过程中声明表变量如下:
DECLARE @tablename TABLE(
a INT,
b INT,
c INT,
d INT);
SELECT * FROM @tablename;
我希望这个答案可以帮到你
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;