May 31, 2011 at 7:36 pm
Hi ,
I want to set the first row third column (e-mail) value as empty. How do i handle?? Can anyone help on this??
Expected output
NAME-----PHONE-------EMAIL
A---------3333---------
B---------4444---------XXX
May 31, 2011 at 8:08 pm
UPDATE myTable
SET email = '' -- or NULL
WHERE name = 'A';
Before you run this, you really need to read up on UPDATE and INSERT in books online. Also, if this is an adhoc request that you are going to run one time (or infrequently) - then you want to wrap it in a transaction just in case...
BEGIN TRANSACTION;
UPDATE ...
ROLLBACK TRANSACTION;
You can then run the above and validate that the correct number of rows have been updated. You could also add SELECT statements to return the updated data (before the rollback) so you can validate the data was updated correctly.
When you are satisfied that the code is working as you expect, change the ROLLBACK to a COMMIT and run it. The COMMIT will make the change permanent and viewable by everyone.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
June 1, 2011 at 7:17 am
thundersplash845 (5/31/2011)
Hi ,I want to set the first row third column (e-mail) value as empty. How do i handle?? Can anyone help on this??
Expected output
NAME-----PHONE-------EMAIL
A---------3333---------
B---------4444---------XXX
I've just gotta ask... Why do you want to do this only to the "first"row?
--Jeff Moden
Change is inevitable... Change for the better is not.
June 1, 2011 at 8:02 am
if you are doing this in Reporing services then i would be more inclined to do this in the report/dataset rather than changes,
you could write an expression either in the dataset or report to handle the same logic that is outlined above, and this would leave the source data intact
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply