Execute SQL Task error - - sql-server

I get the following error when I call a stored proc within an execute sql task in SSIS.
"Description: Executing the query "Exec up_CallXXX" failed with the following error: "Incorrect syntax near '13'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly."
This is how it is set up:
ResulSet : None
ConnectionType : OLE DB
SQLSourceType : Direct input
SQL Statement : Exec up_CallXXX
IsQueryStoredProcedure : False
BypassPrepare : True
The stored proc runs fine when I execute it through SSMS.
Does anyone have an idea what is going on.
Thanks!

This isn't really a complete answer, but the quickest route to troubleshooting this problem is likely to be to capture the command that SSIS is actually trying to execute using a SQL profiler trace, since I think SSIS uses sp_executesql to carry out "Execute SQL" tasks.
Once you have the text of the query SSIS is running, you may find that you can replicate the error if you execute it in SSMS.
I've had this kind of problem when the session settings for my SSMS session are different from the session settings used by SSIS/SSRS. Given the error message, it might be worth checking the SET QUOTED IDENTIFIER values in both sessions - but this is a guess.

Related

issues in executing as400 command from SSIS execute sql task

I am working on an ssis package to process data from text file into as400 system. In one of the steps, i have to create a copy of an existing file object in iseries and i am executing the below command from execute sql task.
{CALL QSYS.QCMDEXC('CRTDUPOBJ OBJ(CKFMTWRK) FROMLIB(MYWRKLIB) OBJTYPE(*FILE) TOLIB(MYWRKLIB) NEWOBJ(CKFMTWRKPN) DATA(*NO)',0000000101.00000)}
This command works fine when i run it from the IBM Personal Communications terminal but throws below error when i do it from SSIS package.
[Execute SQL Task] Error: Executing the query "CALL QSYS.QCMDEXC('CRTDUPOBJ OBJ(CKFMTWRK) FROMLIB..." failed with the following error: "Routine *N in *N not found with specified parameters. SQLSTATE: 42884, SQLCODE: -440". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Further information on my environment:
I'm using sql server data tools 2015.
I've established the connection to as400 using Microsoft OLEDB provider for DB2.
I have sufficient permissions on the server (i guess, coz i am able to execute the commands from the terminal)
This is my first ever with as400 and I am stuck here in this step. I tried looking up online but there is nothing much that could help me in resolving this.
Any suggestions/help on this would be much appreciated.
Thanks.
Dvr
You are trying to perform AS/400 OS level command from a SQL environment (SSIS) which is not correct. QCMDEXEC is AS/400 command line interpreter while CRTDUPOBJ is creation of an identical object from the source with the option to duplicate its data as well.
Personal Communication terminal is fine cos you think you are using SQL service but actually not. It's AS400 command.
End up, you better do it over AS/400 terminal for duplicating object. Just use
CRTDUPOBJ OBJ(CKFMTWRK) FROMLIB(MYWRKLIB) OBJTYPE(*FILE) TOLIB(MYWRKLIB) NEWOBJ(CKFMTWRKPN) DATA(*NO)
The last keyword DATA(*NO) means create the object only but not the data, so you will get an empty file after completion.

SSIS create file for each row of recordset [duplicate]

have a Stored Procedure which has XML as Output and it shows xml output in SSMS. How should I generate an XML file to a specific location from this Stored Procedure using SSIS. I found a link which suggests using VB and script task to do this.Can this be done without using Script Task ? Also I tried following steps in this link :
How to export from SQL Server to XML
The Package fails at Execute SQL Task itself and gives the error [Execute SQL Task] Error: Executing the query "EXEC USP_PMAXML" failed with the following error: "Could not find stored procedure 'EXEC USP_PMAXML'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Thanks for your time and help.
A) The error you are receiving indicates it cannot find the stored procedure. You will want to verify
the stored procedure exists
The account access the stored procedure has execute permissions for it
The stored procedure exists in the default schema, probably dbo, for the account. {I've seen issues where procedures are created under user schemas [domain\user].USP_PMAXML }
The Connection Manager you are using is pointing the correct server and catalog (database).
B) If you would like to use an out of the box approach and avoid scripting, then remove your Execute SQL Task. Below I show an Execute SQL Task for reproduction purposes. It creates a stored proc that generates XML.
Add a Data Flow Task.
Within the Data Flow Task, add an OLE DB Source.
Configure your OLE DB Source to use the connection manager and the stored procedure we verified is correct from step 1
Assuming there should only be one file generated, add a Derived Column Transformation out of the OLE DB Source and inside of it, define the output file name which I assume is C:\ssisdata\so_xmlExtract.xml. I will further assume you rename the column as FileName. The exact value you would use is "C:\ssisdata\so_xmlExtract.xml" Note the doubling of slashes as we must escape the \ character as well as wrap with double quotes.
At this point, you're ready to use the Export Column Transformation. Examples Export Varbinary(max) column with ssis and
Using SSIS to extract a XML representation of table data to a file

SSIS error loading postgres "timeout expired " Possible failure reasons: Problems with the query, "ResultSet" property not set correctly

I am loading data into a potgres database using ssis and oledb drivers. The package executes inserts and some updates using execute sql task. It runs fine through most of the steps but then fails on one final update sql task and I receive the following cryptic Microsoft error msg.
failed with the following error: "timeout expired
". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.”
The target postgres servers are sitting on ubuntu and it seems that the ssis package runs successfully on one server then randomly fails on another.

SQL Strange Timeout Issue

Ok, so I am trying to create a procedure that call an extended procedure. I am getting the following error:
Msg 121, Level 20, State 0, Line 0
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
Even with the simplest test I get that error:
CREATE PROCEDURE Test
AS
BEGIN
EXEC xp_cmdshell 'dir *.exe'
END
However if I just run xp_cmdshell 'dir *.exe' by itself it works.
This is running on a clustered SQL 2005 server. Any help is appreciated.
Are you getting the error when you CREATE the procedure or when you EXECUTE it?
If you get it when you execute it, then there could be some issue with permissions. Since in later versions of sql server calling xp_cmdshell is tightly locked down and by default not enabled in the surface area configuration, I could see a potential for this.
How are you calling the SP? If you're using dynamic SQL, then know that it executes with the privileges of the caller, not the SP creator.
Do you need to prefix the SP with master as in master.dbo.xp_cmdshell?
Have you tried EXECUTE AS either in the SP creation or in the SP execution?
Also, in my experience, transport-level errors are sometimes not due to a problem with the server but a problem with the client caching its connection object past the time when the server has dropped it (thus invalidating the connection object). Given that you're presumably running this within just a short time of initially connecting, it doesn't sound like that is the exact problem, but could you be having some kind of proxy/firewall/net filter issue that is dropping packets because of detecting certain keywords in the packets? I know this is a long shot but I had to ask...

SSIS Exec T-Sql Statement Task connection string

I dragged Execute t-sql statement task from toolbox. clicked new and created new connection.
when i executed, it executed successfully. there was no db showing in con string.
i changed the connection string to point to new server of above in Connection tab.
when i executed it, i recv errr
Description: Executing the query "DBCC SHRINKFILE (AppDB_log,300);" failed with the following error: "Could not locate file 'AppDB_log' for database 'master' in sys.database_files. The file either does not exist, or was dropped. ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. End Error
DBCC Shrinkdatabase command i am using.
Try running the query directly in SSMS in the database where you think it will be run based on your connection. If it fails then it's probably a problem with the query (i.e. the data file really doesn't exist). If it succeeds then it's probably a problem with your connection.
If it's a problem with the connection, try running profiler on your server and see what pops up when you run the SSIS package.
Copuld it be a permissions problem? Do you have the rights to run the command on that database?

Resources