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

more ▼

asked Nov 20, 2009 at 07:18 AM in Default

avatar image

37 3 3 5

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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
more ▼

answered Nov 20, 2009 at 07:20 AM

avatar image

Håkan Winther
16.6k 38 46 58

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Nov 20, 2009 at 07:18 AM

Seen: 2736 times

Last Updated: Nov 20, 2009 at 11:06 AM

Copyright 2018 Redgate Software. Privacy Policy