Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2011-11-17 : 06:49:33
|
| Dear All,I am having following query in store procedure, through this query I am inserting more that 3 Lakh records at a time in EMPLOYEE table from the EMPLOYEE_T table.Now I want to check If insertion is successful then TRUNCATE the EMPLOYEE_T table with If condition. Can anybody please tell me how to do this ?Query:BEGIN TRANSACTION;INSERT INTO EMPLOYEE (EMPID,EMPNAME,MARKS)SELECT EMPID,EMPNAME,MARKS FROM EMPLOYEE_TCOMMIT TRANSACTION;Thanks and Regard'sHarish Patil |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2011-11-17 : 08:05:49
|
| Hello Friend,Can I do as following, Is this correct way or not ?BEGIN TRANSACTION;INSERT INTO EMPLOYEE (EMPID,EMPNAME,MARKS)SELECT EMPID,EMPNAME,MARKS FROM EMPLOYEE_TCOMMIT TRANSACTION;IF @@ROWCOUNT != 0BEGINTRUNCATE TABLE EMPLOYEE_TENDELSEBEGINROLLBACK TRANSACTION;ENDThanks and Regard'sHarish Patil |
 |
|
|
|
|
|
|
|