February 11, 2009 at 5:51 am
Hi guys,
I have a doubt like can i use merge statement for single table insertion and deletion and updation? Moreover the rows which i specified in condition needs to be updated or deleted or inserted.
I have StudentDetails which contains 5 rows.The follwoing is the table structure.
CREATE TABLE StudentDetails
(
StudentID INTEGER PRIMARY KEY
,StudentName VARCHAR(15)
,mark1 decimal(5,2)
,mark2 decimal(5,2)
,mark3 decimal(5,2)
)
can i insert 6 and 7th row and delete the 3 row. and i need to update 2 and 4th row. Is it possible in the single table. please help me out on this.
February 11, 2009 at 6:43 am
Based on the structure and the statement, this sounds like homework. What have you tried so far that hasn't worked?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 11, 2009 at 6:45 am
The MERGE statement is used to merge two tables together so that the destination looks like the source.
Are these inserts, updates and deletes coming from a different table? If not, where's the info coming from that sayds which to insert, which to update and to what, and which to delete?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply