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
 SQL query to compare and update

Author  Topic 

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-07-30 : 08:55:47
I am trying to update a test table from the production table by comparing a text column.The table has 500 records

Can someone please send me the script

X002548
Not Just a Number

15586 Posts

Posted - 2010-07-30 : 09:30:43
ummmm...want to supply us with some details?

Like are the Prod and Test instance on the same server or different servers?

How about the DDL of the 2 tables

Do you really mean a text column datat type or just a char or varchar data type.

How many columns do you need o compare

When you do the compare, HOW do you want to compare?

You know...little details like that

my usb esp port is broken right now



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-07-30 : 09:53:31
The Prod database and the test database are on differant servers,but Iam going to copy the data from the prod table to excel and create a test table in the test database to compare and update.

Iam not sure what you meant by DDL of two tables(Iam new SQL programming Sorry)

The Column Iam trying to compare is of varchar datatype.

I will have to compare only 1 column with has 300 records

When I want to compare I want to compare the Column A of the prod with column A of test and update column B of test

Thanks
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-07-30 : 10:39:21
update Table A
Set
TableA.ColumnA = TableB.ColumnA where
TableA.ColumnB= TableB.ColumnB

I used the above query an getting The multi-part identifier could not be bound error
I know we have to create aliasing for the above query but not where

Can someone please help
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-08-11 : 11:10:19
I was able to fiure it out and update my tables
Go to Top of Page
   

- Advertisement -