Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Good practice to separate If Endif
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
01681311
Message ID:
01681339
Views:
21
Thank you, Naomi. I will try your suggestion.

>Hi Dmitry,
>
>I don't think there is a really simple way (except for RAISERROR with LOG option, but I forgot what exactly does it do).
>
>It also depends on which mode do you execute your SP - in sqlcmd mode the output will go to a file.
>
>Try also googling on the 'T-SQL Log files' and see what other developers suggest.
>
>>Thank you, Naomi.
>>
>>Do you know if the SP code can write a file to a drive? In my VFP 9 or ASP.NET, when I want to check what is going on during the run-time, I write small "log" files. Just to know that this Condition or that Condition has been met.
>>Do you know if this is possible in a SQL Server SP?
>>
>>>Hi,
>>>
>>>T-SQL is really very limited language in terms of the things like SWITCH (or CASE). You would need to do
>>>
>>>IF 
>>>  begin
>>>    code here
>>>  end
>>>ELSE
>>>   begin
>>>       IF other condition
>>>           begin
>>>             some code
>>>            end
>>>    END
>>>
>>>
>>>In T-SQL you can use GOTO someLabel. I don't like this construct myself, but here I see it used a lot in the stored procedures.
>>>
>>>>Hi,
>>>>
>>>>I am troubleshooting a fairly large stored procedure. And I think the issue is that some IF - ENDIF do not separate various conditions. Even though I use BEGIN and END.
>>>>What is a good practice to separate various IF conditions in a stored procedure?
>>>>
>>>>TIA
>>>>
>>>>UPDATE. I also wanted to find out if there is a way to use ELSEIF in a stored procedure. I know you can do ELSE, but if I wanted to have multiple conditions, ELSEIF would be helpful. Or, is CASE - END the only way to have multiple conditions.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform