April 24, 2014 at 1:17 pm
Hail everyone
The other day my client app throws an error based on a store procedure called 'spUsuarios', the error was:
Mens 102, Nivel 15, Estado 1, Procedimiento SpUsuarios, Línea 176
Sintaxis incorrecta cerca de 'Begi'.
After i opened the SP, i checked the error line and i found this. Check Img1
Like 1 Hr later, testing and breaking my head over the wall, i found the solution was this. Check Img2.
Weird!
Anyone can help me to discover what happened here? anything i need to know about inline if??
By the way this error doesn't happen to me in SQL2008, it does in SQL2012.
Also i created this query and nothing happend.
declare @Caja_pos char(6)
set @Caja_pos=''
If @Caja_pos='' Or @Caja_pos Is Null Set @Caja_pos='Ningun'
begin try
select @Caja_pos
end TRY
begin catch
end catch
Would be very grateful if someone help me to understand what happened here. Thanks.:cool:
April 24, 2014 at 1:30 pm
just a shot in the dark here, but this specific error:
Sintaxis incorrecta cerca de 'Begi'.
to me, that implies that a string, say a VARCHAR(50), had a command in it longer than the entire command is, and got truncated in the middle of the word "BEGIN"
could it be there's some dynamic SQL int he full code, and by coincidence, you ALSO made the dynamic string larger, but also added your being / end blocks?
so you think the fix was begin/end, but the fix was really a larger variable?
Lowell
April 24, 2014 at 1:36 pm
Never seen anything like that happen but you could simplify this quite a bit.
declare @Caja_pos varchar(6)
select @Caja_pos = 'Ningun' where isnull(@Caja_pos, '') = ''
select @Caja_pos
_______________________________________________________________
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/
April 24, 2014 at 1:48 pm
Hello Lowel, well this is not dynamic query is a normal T-SQL Code, about the error message "Sintaxis incorrecta cerca de 'Begi'." this message is in spanish, in english is "Incorrect syntax near 'Begi'". About my "solution" was adding Begin and End on the inline as you can see in the image abov and after this, the error doesn't happen any more. I really don't know what else could have happen, maybe high transactionality level, maybe the was the motor 2012 (because in 2008 doesn't happen.) w/e.
Reggards
April 24, 2014 at 1:53 pm
Hello SSChampion
About my example code, i created this to test in a additional query i could get the error again but i didn't, about the "Begin try" i did because after the inline if, the next code is a begin try, after a begin tran etc etc ...
Well, like i answer to Lowel, my solution was add a "Begin" and "End" on the code and it seems have working very good.
Reggards
April 24, 2014 at 1:53 pm
so wierd;
i speak spanish, albiet not as a primary languange, but i had no trouble with the error messages, it's just the error says syntax near BEGI and not BEGIN, which makes me think truncation.
Lowell
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply