SSIS 2010 update table with decimal data type gives error "type not supported.DBTYPE_DECIMAL" - sql-server

Strange error, Using SSIS 2010 on 2012 Enterprise Edition db.
Using OLEDB connection.
Variable a,b,c are defined as Decimal in ssis.
d is defined as a String.
Sql Task:
Select min(col1),max(col1) from table_a
where key_value = ?
where: parameter 0 is d , data type=Varchar
resultset 1 is a , 2 is b
Expression task:
#[User:c] = (DT_DECIMAL,2) (#[User:a] + #[User:b])
Sql Task:
Update table_a
set col2 = ?
where key_value = ?
where: parameter 0 is c (DataType=DECIMAL) and 1 is d (DataType=Varchar)
Error: ... failed with the following error: "The type is not
supported.DBTYPE_DECIMAL". Possible failure reasons: Problems with
the query, "ResultSet" property not set correctly, parameters not
set correctly, or connection not established correctly.
table_a is defined as
d varchar(4),
col1 numeric(10,2),
col2 numeric(10,2)
There are multiple rows of d and no index on table...
I've tried casting and converting the value in the update statement
Any ideas what's in error ?
Thanks

Check the parameter mapping section of your SQL task(s) to ensure the parameters are set properly.
I've seen this before, 'parameter not set correctly' is the key.

Related

Netezza : Update error : cross database connection not supported for this type of command

I am trying to update a table in Netezza getting below error
"Update table table1
set col1 = val1
where col2 = "xx"
I am getting below error :
"Netezza : cross database connection not supported for this type of command "
what could be the possible reason
You need to ‘switch’ to the database where the ‘table1’ is located. Many people connect to the SYSTEM database, but it’s a bad idea to put your tables/views there. In this example, I assume that table1 is in the EDW database:
Set catalog EDW
;
Update table table1 set col1 = val1 where col2 = ‘xx’
;
I hope that makes sense to you?

SSIS Pass variable to Execute SQL Update [duplicate]

I have ssis package in that I'm taking values from flat file and insert it into table.
I have taken one Execute SQL Task in that creating one temptable
CREATE TABLE [tempdb].dbo.##temptable
(
date datetime,
companyname nvarchar(50),
price decimal(10,0),
PortfolioId int,
stype nvarchar(50)
)
Insert into [tempdb].dbo.##temptable (date,companyname,price,PortfolioId,stype)
SELECT date,companyname,price,PortfolioId,stype
FROM ProgressNAV
WHERE (Date = '2011-09-30') AND (PortfolioId = 5) AND (stype in ('Index'))
ORDER BY CompanyName
Now in above query I need to pass (Date = '2011-09-30') AND (PortfolioId = 5) AND (stype in ('Index'))
these 3 parameter using variable name I have created variables in package so that I become dynamic.
In your Execute SQL Task, make sure SQLSourceType is set to Direct Input, then your SQL Statement is the name of the stored proc, with questionmarks for each paramter of the proc, like so:
Click the parameter mapping in the left column and add each paramter from your stored proc and map it to your SSIS variable:
Now when this task runs it will pass the SSIS variables to the stored proc.
The EXCEL and OLED DB connection managers use the parameter names 0 and 1.
I was using a oledb connection and wasted couple of hours trying to figure out the reason why the query was not working or taking the parameters. the above explanation helped a lot
Thanks a lot.
Along with #PaulStock's answer, Depending on your connection type, your variable names and SQLStatement/SQLStatementSource Changes
https://learn.microsoft.com/en-us/sql/integration-services/control-flow/execute-sql-task
SELECT, INSERT, UPDATE, and DELETE commands frequently include WHERE clauses to specify filters that define the conditions each row in the source tables must meet to qualify for an SQL command. Parameters provide the filter values in the WHERE clauses.
You can use parameter markers to dynamically provide parameter values. The rules for which parameter markers and parameter names can be used in the SQL statement depend on the type of connection manager that the Execute SQL uses.
The following table lists examples of the SELECT command by connection manager type. The INSERT, UPDATE, and DELETE statements are similar. The examples use SELECT to return products from the Product table in AdventureWorks2012 that have a ProductID greater than and less than the values specified by two parameters.
EXCEL, ODBC, and OLEDB
SELECT* FROM Production.Product WHERE ProductId > ? AND ProductID < ?
ADO
SELECT * FROM Production.Product WHERE ProductId > ? AND ProductID < ?
ADO.NET
SELECT* FROM Production.Product WHERE ProductId > #parmMinProductID
AND ProductID < #parmMaxProductID
The examples would require parameters that have the following names:
The EXCEL and OLED DB connection managers use the parameter names 0 and 1. The ODBC connection type uses 1 and 2.
The ADO connection type could use any two parameter names, such as Param1 and Param2, but the parameters must be mapped by their ordinal position in the parameter list.
The ADO.NET connection type uses the parameter names #parmMinProductID and #parmMaxProductID.
A little late to the party, but this is how I did it for an insert:
DECLARE #ManagerID AS Varchar (25) = 'NA'
DECLARE #ManagerEmail AS Varchar (50) = 'NA'
Declare #RecordCount AS int = 0
SET #ManagerID = ?
SET #ManagerEmail = ?
SET #RecordCount = ?
INSERT INTO...

SSIS Execute SQL Task Stored Procedure returning empty result sets

I have a simple stored procedure that returns 1 row with 3 columns. I am trying to create an SSIS package that reuses the values in these columns later. If I run a simple select query everything is happy but when I run the stored procedure I get the following error:
[Execute SQL Task] Error: Executing the query "rs_UpdateMemberExtract"
failed with the following error: "Unable to populate result columns
for single row result type. The query returned an empty result set.".
Possible failure reasons: Problems with the query, "ResultSet"
property not set correctly, parameters not set correctly, or
connection not established correctly.
I've set up an ado.net connection and the proc runs correctly in SSMS, I have the task set up like follows:
ConnectionType: ADO.NET
Connection: ServerName.connectionName
SQLSourceType: Direct Input
SQLstatment: Name of Proc (rs_UpdateMemberExtract)
IsQueryStoredProcedure: True
I have each parameter mapped to a variable and the direction set to Output
I have the name of each column that should be returned in the result set and mapped to the associated variable.
The task works if I set the ResultSet to 'None',
Any ideas What I've missed?
Thanks
If an SQL Task Editor expects results returned in a row … but there are no records to return then the following SQL fills a null return with a space. Note : can also be used to return zero if a numeric “return row” is expected
SELECT '' + ISNULL ((SELECT x FROM y WHERE (z = ?)), '') AS myfield

Storing System::StartTime in SSIS to a datetime column [duplicate]

I am working in SQL Server 2008 and BIDS (SSIS). I am trying to generate a "load ID" for when a package is executed and store that ID in a load history table (which then populates subsequent tables).
My basic SSIS control flow is the following:
Execute SQL Task, Data Flow Task
The load table is created via the following:
CREATE TABLE dbo.LoadHistory
(
LoadHistoryId int identity(1,1) NOT NULL PRIMARY KEY,
LoadDate datetime NOT NULL
);
The editor for the Execute SQL Task is as follows:
General:
ResultSet = None
ConnectionType = OLE DB
SQLStatement:
INSERT INTO dbo.LoadHistory (LoadDate) VALUES(#[System::StartTime]);
SELECT ? = SCOPE_IDENTITY()
Parameter Mapping:
Variable Name = User::LoadID
Direction = Output
Data Type = LONG
Parameter Name = 0
Parameter Size = -1
SSIS is throwing the following error:
[Execute SQL Task] Error: Executing the query "INSERT INTO dbo.LoadHistory
..." failed with the following error: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
This error message doesn't really help me find the problem. My best guess is that it's due to the parameter mapping, but I don't see my mistake. Can anybody point out my problem and provide the fix?
I figured out my problem. System::StartTime needs to have DATE as its data type, not DBTIMESTAMP.
I was passing three parameters.
In the Parameter Name property I had:
0
1
3
Corrected it to:
0
1
2
It works now, no multiple-step operation generated errors message.

Database Connector Error

I have created a stored procedure for my report..
create Procedure [dbo].[sp_Score_Grade]
#Month int,
#Year int,
#Log_User varchar(30)
AS
(
SELECT Log_User, Count = COUNT(Det_Score), Score = SUM(Det_Score)
FROM MEMBER M,DETAILS D
WHERE D.Emp_Id = M.Emp_Id AND
Log_User like '#Log_User'
AND Month(Sched_Start) = '#Month'
AND Year(Sched_Start) = '#Year'
GROUP BY Log_User
)
And when the Crystal Report dialog box appear asking for parameters, I check all the values to null. But before i proceed to the next step. The error below displayed.
Database Connector Error:
Source: Microsoft OLE DB Provider for SQL Server
Description: Conversion failed when converting the varchar value '#Month' to data type int
SQL State: 22018
Native Error: 245[Database Vendor Code: 245]
I am hoping that someone here can explain to me why I get this error and how will I do...
Im using MS SQL Server 2005 and Crystal Report for VS2010..
thanks in advance. :D
Your parameter names are delimited in the query, so SQL Server is treating them as literal strings. Try
Log_User like #Log_User
AND Month(Sched_Start) = #Month
AND Year(Sched_Start) = #Year

Resources