I want to create SQL variable table in stored procedure which include this;
Select a,b,c,d from **@tablename** where a=1 and c=0
How can do this with sp when creating sp?
I want to create SQL variable table in stored procedure which include this;
Select a,b,c,d from **@tablename** where a=1 and c=0
How can do this with sp when creating sp?
You can declare table variable in SP as:
DECLARE @tablename TABLE(
a INT,
b INT,
c INT,
d INT);
SELECT * FROM @tablename;
I hope this answer helps you
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;
© 2022 - 2024 — McMap. All rights reserved.