March 4, 2011 at 2:11 pm
So i am updating a table as
Update TableA
SET columnA = Column B
where ColumnA <> ColumnB
and the sql server shows it as 17 rows were affected but what 17 rows in that table are updated is not displayed, is there a way i can display the updated rows as well, in other case the sql server management studio shows reuslts as
1 row updated
2 rows updated
but how can i show what all was updated. can i use the print command to show the update, or is there a setting is management studio that can show us the update
thanks
March 4, 2011 at 2:28 pm
You're looking for the output clause. Check out these links:
Overview: http://msdn.microsoft.com/en-us/library/ms177564.aspx
Usage in Update: http://msdn.microsoft.com/en-us/library/ms177523.aspx
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
March 4, 2011 at 2:47 pm
CREATE TABLE #temp (
NEWVALUE varchar(100),OLDVALUE varchar(100) )
Update MYTABLE
SET COLUMNA = COLUMNB
OUTPUT
INSERTED.COLUMNA,
DELETED.COLUMNA
INTO #temp(NEWVALUE,OLDVALUE)
where COLUMNA <> COLUMNB
SELECT * FROM #temp
drop table #temp
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply