October 24, 2011 at 8:49 am
Hi,
I know this may be a basic ??
But I have and Adresss table and I want to run some SQL to update all
address.state='AB" to 'AC"
Thanks in Advance..
Joe
October 24, 2011 at 8:55 am
update table
set column = somevalue
where Some Condition
That help?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
October 24, 2011 at 9:01 am
Hi Sean.
Thanks.. worked perfect..
Still a little gun shy of the update statement..
lol
October 24, 2011 at 9:08 am
Easiest way to make sure your update is not doing something really bad is to put it in a transaction first.
begin transaction
update blah blah
rollback transaction
If you see a reasonable rowcount you are probably ok. If you see a rowcount of 1,8475,938 records and you expected about 8 then there is probably something not quite right.
So I have to ask, what do you have state field in an address table that has 'AB' and you are updating to 'AC'??? Shouldn't you use the standard state codes?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
October 24, 2011 at 9:36 am
I had the codes wrong...
actually when someone did a conversion they put in 22 instead of MA ..
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply