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
 Generating update script for large numbr of rows

Author  Topic 

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-12-23 : 09:33:33
Need some direction to update rows in our tables

Are there any tools to generate queries to update rows in bulk.In the below Example script Iam trying to update our contact table with workid and employeeid of employees based on their contact_id and email

I am not sure how do i generate queries to update 1000 records at a time.Doing it manually is eating up my time


UPDATE contact SET workid='xyxxx',empid='12345678' WHERE contactid=8976 AND email='xyz1234@yahoo.com;

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-12-23 : 09:40:56
Do you want to update the same for all rows?


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-12-23 : 09:42:19
Nope.It is differant workid,empid for differant contactid's

Thanks
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-23 : 09:54:11
Are you fetching data from other table ?

I mean for

UPDATE contact SET workid='xyxxx',empid='12345678' WHERE contactid=8976 AND email='xyz1234@yahoo.com;

Where you are getting values from ?
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-12-23 : 10:03:40
The values from our Corporate ldap tables
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-23 : 11:37:12
If there is relationship between both the tables then you can do inner join and update it in single statement.

In case you are having issue the please provide some sample data for both the tables (contact & corporate) and whats the relationship they share. May be then we can give exact update statement to help you.
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-12-24 : 18:28:07
I get the updated list of contacts information for our local contact table from our corporate active directory.
It is always in the form of excel.

How do i Write a query to bulk update our contact table from the excel sheet.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-12-27 : 08:09:51
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-12-27 : 08:56:04
There is RedGate DataCompare and Atlantis Visual Inspector.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2010-12-27 : 10:24:47
Thanks everyone for posting the links,were helpful
Go to Top of Page
   

- Advertisement -