Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting data to existing table 1

Status
Not open for further replies.

JLizOB

Programmer
Dec 5, 2007
45
CA
I have two tables, on two different SQL Servers, one locally, and another in a development environment, and they are identical in terms of columns and data types etc... the only difference is one has data and the other is completely empty. I created a link between the two servers, and want to insert all of the rows into the empty table. I've been trying things like:
Code:
Insert into FIDO..stg_FIDO Values(Select * From DevelopmentServerLink.FIDO.dbo.stg_FIDO)

Select * into FIDO..stg_FIDO from DevelopmentServerLink.FIDO.dbo.stg_FIDO
but haven't had any luck yet. Are there any scripts that would accomplish this? Thanks!
 
Code:
Insert into FIDO..stg_FIDO 
Select * From DevelopmentServerLink.FIDO.dbo.stg_FIDO

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Code:
Insert into FIDO..stg_FIDO (field1, field2)
Select field1, field2 From DevelopmentServerLink.FIDO.dbo.stg_FIDO

Always specify the exact fields you want. Inthe first place you may not want to copy over timestamp fields or identity fields. In the second place, if someone takes it into his head to change the column order on one the tables, you wan't be putting the social security number into the honorarium filed by accident.

BTW select into only works if the table does not exist.

"NOTHING is more important in a database than integrity." ESquared
 
Uggh shoulda known that, thanks for your help everyone!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top