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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Script to append data to column"X"

Status
Not open for further replies.

wfairban

IS-IT--Management
Mar 13, 2006
11
US
Currently I have column X in table A,B,C,D,etc. I need to append a "-E" on the end of all rows in Column X. What is the easiest way to do this?
 
Look at FAQ183-4107. There is an undocumented procedure that lets you run upto three commands against every database or table. Just use the sp_MSForEachTable command. It should run a command something like:

UPDATE ?
SET x = x + '-E'

In MSForEachTable, the ? is replaced with each table name.

-SQLBill

Posting advice: FAQ481-4875
 
Ok that worked great. Now I have another issue.

Spreadsheet has 2 columns: A = xnum and B = xnum + -E.
Database has a field in various tables called pnum. I need to update pnum with all xnum from column A = pnum in db then add -E on it.

I hope you are not as confused as I am..............


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top