question

Binoy avatar image
Binoy asked

how can we use "Select into" statement with a newly declared table(Stored procedures)

I have declared a temp table @table in procedure and while using the "select into" statement with the temp table getting an error. Is there any way to solve this problem?

DECLARE @table TABLE ([name] varchar(50))

SELECT emp_name INTO @table FROM tbl_Employeemaster

Thanks in Advance

t-sqlstored-procedures
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Håkan Winther avatar image
Håkan Winther answered

You can't do a select into a table variable or an existing table (not even a temporary one) You need to do:

insert into (x, y) SELECT t.x,t.y FROM Table1 AS t
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.