Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Changing Table DB

Author  Topic 

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-05-14 : 03:00:06
i have a table in northwind Db right now i want to change it to the adventureworks Db. can u give me a suggestion.

KaShYaP

karthik_padbanaban
Constraint Violating Yak Guru

263 Posts

Posted - 2010-05-14 : 03:08:20
run the script in adventureworks DB. replace <tablename> with yours.

use adventureworks
select * into <TableName> from northwind..<TableName>

Karthik
http://karthik4identity.blogspot.com/
Go to Top of Page

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-05-14 : 03:15:54
it works but i can't find the table in adv db for ex table name is actors which is in north wind can you modify your query plz

KaShYaP
Go to Top of Page

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-05-14 : 03:30:00
yes it works but it is copying the table i want to replace the full data from north wind to Adventure without duplicates in northwind

KaShYaP
Go to Top of Page

karthik_padbanaban
Constraint Violating Yak Guru

263 Posts

Posted - 2010-05-14 : 03:57:57

try this.
select col1,col2 into <tablename> from
(select *,row_number()over(partition by col2 order by col2) as col3 from northwind..<tablename>) a
where a.col3 = 1

Karthik
http://karthik4identity.blogspot.com/
Go to Top of Page

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-05-14 : 06:02:46
Example:-

Filmid. FirstName. LastName.
1. Audrey. Hepburn.
1. Rex. Harrison.
3. Anthony. Hopkins.

This is the table which is present in Northwind. the Name of the table is actors
Plz consider

KaShYaP
Go to Top of Page

karthik_padbanaban
Constraint Violating Yak Guru

263 Posts

Posted - 2010-05-14 : 08:50:57
quote:
Originally posted by kashyapsid

Example:-

Filmid. FirstName. LastName.
1. Audrey. Hepburn.
1. Rex. Harrison.
3. Anthony. Hopkins.

This is the table which is present in Northwind. the Name of the table is actors
Plz consider

KaShYaP




then this thing will work..

use adventureworks
select * into <TableName> from northwind..<TableName>


Karthik
http://karthik4identity.blogspot.com/
Go to Top of Page
   

- Advertisement -