开发者

How to extract a database columns(and their data) into a new table?

I have a table in ms sql 2008 and I want to take 2 columns(the pk and an开发者_StackOverflow中文版other column) and put it into a new table.

How can I extract all the data in these columns already and put them in the new database?


If you want to create a new table then you can try

SELECT .... INTO... FROM

E.G:

SELECT Pk_Column, Other_Column
  INTO NewTable
  FROM CurrentTable

If you have already created the table then try INSERT .... INTO .... SELECT .... FROM

INSERT INTO NewTable   
SELECT Pk_Column, Other_Column   
  FROM CurrentTable 


INSERT INTO targetdb..targettable(personfirstname, personlastname) 
SELECT firstname, lastname FROM sourcedb..sourcetable
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜