November 6, 2008 at 7:49 pm
I am sorry to ask this stupid question..but i had this doubt when i was at work...i had one sql file which had three inserts on a table..
begin
insert(...inserting rows on a table)
/*
commit
*/
i was first suppose to execute the code...then highlight the commit and then execute...i remember that i did execute the code..but i dnt rem whether i highlighted the "commit" and then executed..i checked the table...data is been inserted...so why do we have to use begin and commit...cant we just insert the records...i just want to make sure that im safe...again the records and inserted..but im not sure whether i committed the transaction or not..thx
November 6, 2008 at 8:30 pm
If you did a begin transaction you need to do a commit. You can run DBCC OPENTRAN() to determine if you left the transaction uncommitted.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
November 6, 2008 at 9:20 pm
You need to use begin and commit, when you are trying to run a batch. Either the entire upload is successful or nothing is updated.
I think SQL server also has an auto commit feature....
Please correct me if i am wrong....
Thanks & Regards,
Sudeepta.
http://twitter.com/skganguly
November 7, 2008 at 1:08 am
i checked the table...data is been inserted...
How did you check?
In the same connection it is possible to see the records without COMMITing.
In the other connection also it is possible to see with NOLOCK hint. It's called dirty read. Reading uncommitted rows.
November 7, 2008 at 1:21 am
set the isolation levels for database. So don't worry about whether record is commited or not.
for more info see SQL BOL.
November 7, 2008 at 2:45 am
Kishore.P (11/7/2008)
set the isolation levels for database. So don't worry about whether record is commited or not.for more info see SQL BOL.
COMMIT matters, even if ISOLATION LEVEL is SET. It cannot be ignored.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply