February 22, 2008 at 12:15 pm
I have to create table from select querry
drop MyNewTable
SELECT *
INTO MyNewTable
FROM top (10)........
and is very important to create unique identifier ID column in MyNewTable for each record i'm inserting.
or instead of creating and droping MyNewTable how can I just update MyNewTable with the results from select statement
February 22, 2008 at 12:44 pm
This should work for you.....
drop MyNewTable
SELECT IDENTITY(int,1,1) as RowID, t.*
INTO MyNewTable t
FROM top (10)........
If this is in a stored proceudre, I would suggest that you explicitly define the table and then use the INSERT INTO...SELECT FROM construct instead.
February 22, 2008 at 1:05 pm
Agree with John - with a few syntax corrections....
drop table MyNewTable
SELECT top (10) IDENTITY(int,1,1) as RowID, * --top 10 need to be in the SElect, not the from
INTO MyNewTable
FROM ...
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
February 22, 2008 at 1:15 pm
February 22, 2008 at 1:41 pm
Thank you guys.This answered my question
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply