Akshay Sawant
Akshay Sawant

Reputation: 53

How to copy rows from table variable into a normal table in MS SQL?

I have a sql query wherein the output(rows) of my query are gathered in a table variable named "@Data" and the number of rows generated as output are around 50000. How can I copy those rows in to a table which is present in my SQL database? I am using MS SQL.

Thanks in advance.

Upvotes: 0

Views: 436

Answers (1)

roman
roman

Reputation: 117350

insert into <your table name> (
    <columns>
)
select
    <columns>
from @Data

As a side note, using table variables with number of rows ~50K usually do not gives you good performance, you can consider temporary tables instead

Upvotes: 1

Related Questions