Msdb.dbo.sp_send_dbmail Error Formatting Query
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Msg 22050, Level 16, State 1, Line 0 Error Formatting Query, Probably Invalid Parameters
of this site About Us Learn more about Stack Overflow the company Business error formatting query probably invalid parameters sql server 2008 Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Failed To Initialize Sqlcmd Library With Error Number -2147467259. [sqlstate 42000] (error 22050)
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: sp_send_dbmail permission Sign up sp_send_dbmail executed from job fails with query result attached as file up vote 10 down vote favorite 3 I have faced with the following issue: when trying to send email with results of query attached as file, using sp_send_dbmail via executing ordinary query everything seems to be working OK. But if add the same code into JobStep and run the job, error 22050 informatica it fails. Error in job history says Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050). The step failed. But when I comment out parameter that refers to file attaching it starts working correctly again. exec msdb.dbo.sp_send_dbmail @profile_name = 'profile_name', @recipients = 'some@mail.com', @body = 'body', @subject = 'subj', --Parameters that refers to attached file @attach_query_result_as_file = 1, @query_result_header = 0, @query_result_no_padding = 1, @query = 'select 1', @query_attachment_filename = 'test.csv' Any suggestions? sql-server sql-server-2008 attachment sp-send-dbmail share|improve this question edited Feb 27 '13 at 14:40 marc_s 454k938701033 asked Feb 27 '13 at 13:05 Paul Kyrejto 5191516 Furthermore, even if I wrap this code into a stored procedure, I end up the same –Paul Kyrejto Feb 27 '13 at 13:14 so everything works - you just can't specify the name you want for the return results? have you tried a different name? –Jimbo Feb 27 '13 at 13:19 add a comment| 6 Answers 6 active oldest votes up vote 21 down vote accepted I've come to workaround of that issue. Don't know why would it work but never the less
Recent PostsRecent Posts Popular TopicsPopular Topics Home Search Members Calendar Who's On Home » SQL
Could Not Obtain Information About Windows Nt Group/user Error Code 0x5.
Server 2008 » SQL Server 2008 - General » Email failure - sp_send_dbmail query query formatting Email failure - query formatting Rate Topic Display Mode Topic Options Author Message Chris StrideChris Stride
Failed To Initialize Sqlcmd Library With Error Number Sp_send_dbmail
Posted Friday, January 22, 2010 8:43 AM SSC Rookie Group: General Forum Members Last Login: 2 days ago @ 9:21 AM Points: 26, Visits: 159 Hi,I have recently upgraded from http://stackoverflow.com/questions/15112849/sp-send-dbmail-executed-from-job-fails-with-query-result-attached-as-file SQL Server 2005 (v9.0.4262) Standard Edition 32-bit to SQL Server 2008 (v10.0.2531) Enterprise Edition 64-bit. I have a job which used to email a notification. This worked fine on the old server, but fails on the new. The part that fails is:*************************************************************************************EXEC msdb.dbo.sp_send_dbmail @recipients = 'abc@xyz.com', @subject = 'SQL job step failures from the Warehouse load this morning', @body_format = http://www.sqlservercentral.com/Forums/Topic852110-391-1.aspx 'HTML', @execute_query_database = 'DW_Mart', @query = 'SELECT * FROM DW_Mart.dbo.SQL_job_step_failures;', @query_result_header = 1, @query_result_width = 200;*************************************************************************************The error message returned is:MessageExecuted as user: XXXX\yyyyy. Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050). The step failed.The user this job runs under (exact same properties & permissions as the old server as far as I can see) is a member of the DatabaseMailUserRole on the msdb database.When I run the above SQL (between the '*********'s) in a query window, it executes fine and sends the mail I expect. The issue would appear to be in the query, rather than permissions, but I'm not sure what it could be when it is a valid query which hasn't changed and does return data when run manually in a query window. I have tried adjusting the query_result_width, but with no luck. I've also deleted and re-done the job from scratch - still no luck.Looking through the various SQL Server logs, I can't see any additional information that sheds any futher light on why this is failing. I've tried putting Database Mail in verbose
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time https://www.experts-exchange.com/questions/27257615/sp-send-dbmail-Error-formatting-query-probably-invalid-parameters.html Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups error formatting Website Testing Store Headlines Experts Exchange > Questions > sp_send_dbmail Error formatting query, probably invalid parameters Want to Advertise Here? Solved sp_send_dbmail Error formatting query, probably invalid parameters Posted on 2011-08-15 MS SQL Server 2008 1 Verified Solution 5 Comments 5,774 Views Last Modified: 2012-05-11 error formatting query I am trying to execute the sp_send_dbmail from a SQL Server Agent Job. The procedure runs fine when I execute the T-SQL from my computer. But when I try to get it run in a Job I get this error Executed as user: DOMAIN\SQLAgent. Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050). The step failed. Here is my statement EXEC msdb.dbo.sp_send_dbmail @profile_name = 'DatabaseMail1', @recipients = 'user@domain.com', @query = 'SELECT RecordNumber ,SplitName ,GradeOfService FROM Database.dbo.Table AS cw WHERE (ReportDate = CONVERT(nvarchar, GETDATE(), 101))', @subject = 'Subject' Select all Open in new window If I pull out the @query it works fine from the server. Thank You 0 Question by:vbchewie Facebook Twitter LinkedIn Google LVL 4 Best Solution byanandarajpandian Hi, Please check below link, http://social.msdn.microsoft.com/Forums/en/sqlnotificationservices/thread/08a713ad-6215-4ffd-ba1b-540567082b87 http://dbaspot.com/sqlserver-programming/188624-sql-2005-sp_send_dbmail