Home RC ignored - Failed to initialize sqlcmd library with error number -2147467259
Reply: 0

RC ignored - Failed to initialize sqlcmd library with error number -2147467259

user1011
1#
user1011 Published in June 20, 2018, 10:46 pm

I have an example query that I am purposely failing as the db and table doesn't exist as part of my test

declare @nsql nvarchar(4000)
,@rc int
set @rc = 0
set @nsql = '
EXECUTE msdb.dbo.sp_send_dbmail
@subject = ''test sub''
,@recipients = ''joe.bloggs@myemail.com''
,@copy_recipients=''null''
,@blind_copy_recipients=''null''
,@body=''test body''
,@Query = ''select * from mydb..tlist'' ,@query_result_header =0 
'
begin try
exec @RC = sp_ExecuteSQL @NSQL
end try
begin catch
    set @RC=@@ERROR
end catch

print @rc

On my SQL2008 server I get this response

Msg 22050, Level 16, State 1, Line 0 Error formatting query, probably invalid parameters RC:14661

On my SQL2014 server I get this response

Msg 22050, Level 16, State 1, Line 0 Failed to initialize sqlcmd library with error number -2147467259. RC:0

My query/issue is why on SQL2014 am I getting a 0 RC? Its not recognising the failure?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.304885 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO