[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 642
  • Last Modified:

Use of EXEC , string and INTO....

Hi,
I've got a query wich is execute with EXEC.
I need to do this:

@QUERY = select col1 as C1,col2 as C2,col3 as C3 from TABLE

exec(@QUERY)

insert into TABLE2 values(C1,C2,C3)

////////////////////////////////////////////////
I need in fact to insert in TABLE2 the result of the query.

Thanks for your help .
0
bruno_boccara
Asked:
bruno_boccara
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
Hello bruno_boccara,

insert into TABLE2
exec(@QUERY)





Aneesh R
0
 
ee_rleeCommented:
try this

@QUERY = insert into TABLE2 (C1,C2,C3)  select col1,col2,col3 from TABLE
exec(@QUERY)
0
 
bruno_boccaraAuthor Commented:
Thanks you....
0
 
Greg BessoIT Solutions EngineerCommented:
ee rlee, just saw your post here and it helped me get something done I was spending all morning on. I hate being a newb with T-SQL, but it's nice to finally get through problems.

Thx!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now