Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Why no statement executed in the below insert.. Expand / Collapse
Author
Message
Posted Monday, August 12, 2013 2:20 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, December 18, 2014 7:50 AM
Points: 84, Visits: 292
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.
Post #1483178
Posted Monday, August 12, 2013 6:34 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Thursday, December 18, 2014 12:52 PM
Points: 13,636, Visits: 11,509
Probably because they were never executed at all.
The compiler noticed a syntax error in your script, so it gives an error straight away.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1483261
Posted Monday, August 12, 2013 7:37 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 2:05 PM
Points: 13,327, Visits: 12,820
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1483308
Posted Wednesday, August 21, 2013 2:19 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, November 24, 2014 4:58 PM
Points: 522, Visits: 241
What is your intention by putting BREAK?
Post #1486926
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse