Hi Guys,
I tried to run below query
but it returned only empty column and it should print 'CATCH entered'Quote:
BEGIN TRY
SELECT 1/0
print 'Hello'
END TRY
BEGIN CATCH
print 'CATCH entered.'
END CATCH
Could You please help me with that?
Printable View
Hi Guys,
I tried to run below query
but it returned only empty column and it should print 'CATCH entered'Quote:
BEGIN TRY
SELECT 1/0
print 'Hello'
END TRY
BEGIN CATCH
print 'CATCH entered.'
END CATCH
Could You please help me with that?
I have founded how it should look like:
Could You please explain to my why it should like like above?Quote:
BEGIN TRY
declare @var int = 1/0
print 'Hello'
END TRY
BEGIN CATCH
print 'CATCH entered.'
END CATCH
Both work. The message is printed on Messages tab on the result window, because of SELECT statement the first window is for resultset. In second post, you don't have SELECT so there is only Message tab in the result.
@skhanal
So how should look like the query in first post to print 'CATCH entered'?
I know if I will use select instead of print in CATCH block I will see two results windows.
What if I want to return only one result window with mentioned 'CATCH entered'?
You can change the management studio setting to "Results to Text"