August 12, 2013 at 2:20 am
hi,..
I know the break is only used with in the scope but
I have used the break between the insert statements..,
why does the first 4 insert statements are rolled back instead of insert..Please help upon this..
insert into TestTable values ('giri');
insert into TestTable values ('giri');
insert into TestTable values ('giri');
insert into TestTable values ('giri');
BREAK:
insert into TestTable values ('giri5')
insert into TestTable values ('giri6')
insert into TestTable values ('giri7')
select * From TestTable
The error:
Msg 135, Level 15, State 1, Line 6
Cannot use a BREAK statement outside the scope of a WHILE statement.
August 12, 2013 at 6:34 am
Probably because they were never executed at all.
The compiler noticed a syntax error in your script, so it gives an error straight away.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
August 12, 2013 at 7:37 am
The next question is why do you have inserts within a while loop?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 21, 2013 at 2:19 pm
What is your intention by putting BREAK?
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply