I have written a case statement as :
Case when currency=‘Abc’ then outstanding_bal else null end as outstanding _balances_RO
And i my job is failing saying this error messege
Source is ODBC connector , connected to Microsoft SQL server.
Schema reconciliation detected a type mismatch for field outstanding_balances_RO . When moving data from field type varchar(min=0,max=58) into Decimal (15,3)
Since you're already using an expression in the SELECT statement, wrap that expression in a CAST to force it to DECIMAL(15,3) data type.
Related
In SQL server, I have a table with 'smalldatetime' data type for one of the column. When I am trying to export the data using Microsoft SQL server import/export wizard, it is giving me conversion error because the field contains NULL value in Date field. Can you please help me in resolving this error.
What steps need to be followed in order to resolve the conversion error.
Are you trying to copy "table to table" or "query to table"?
Cause if your problem is only with null values you can write a query and use ISNULL() function.
Can you post the error here? I´m asking cause maybe your problem isn´t it. Maybe you´re trying to convert a type into another that is not compatible.
Good Afternoon All,
I have spent about 6 hours trying to get formatting to work through SSIS using a Max Date Variable to identify into a where clause - Just have no luck!
I have created a variable called my_date which fetched the Max(Date) from a local SQL server table to understand the last load point for that table - using the below code:
SELECT CAST(FORMAT(MAX(Business_Date), 'dd-MMM-yyyy') AS varchar) AS my_date FROM Table
This fetches the date correctly as 17-Sep-2018.
I have then mapped my result set as my_date -> User::max_date
I have set my max_date variable to a string data type under the package scope.
I have tested my variable out by using breakpoints to ensure this runs all the way through in the correct format - and this works 100%.
I then have a data flow task running to fetch data from my ORACLE DB to insert into my SQL Server table which contains the following SQL command:
SELECT *
FROM Table2
WHERE (BUSINESS_DATE > to_date('#[User::max_date]', 'DD-MON-YYYY'))
However I get the ORA-01858 - [TABLE] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E07.
An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80040E07 Description: "ORA-01858: a non-numeric character was found where a numeric was expected
".
If I go and replace my variable directly with the contents of the variable shown by the breakpoint in locales it works perfectly!
I have attempted multiple format types from the initial export through to the final where clause and this seems to be the closest I have come to pushing it through but it is still complaining about format.
Please help - Images below to help see setup.
Control Flow - displaying the execute SQL and the data flow task
Locale showing Variable is inserting after breakpoint is reached
Managed to get it working!
By adding an intermediary variable where the value and expression contains the following:
"SELECT *
FROM TABLE
WHERE (BUSINESS_DATE > to_date('"+#[User::max_date]+"' , 'DD-MON-YYYY'))"
I then amended my source OLEDB to SQL Command from variable and selected the above variable created and it worked perfectly!
Try mapping your user parameter in the "OLE DB Data Source Editor", under "Parameters".
1) Change SQL Command Text (change #[User::max_date] to ?), like this:
SELECT *
FROM Table2
WHERE (BUSINESS_DATE > to_date('?', 'DD-MON-YYYY'))
2) Then in the parameter editor, map parameter 1 to #[User::max_date].
https://learn.microsoft.com/en-us/sql/integration-services/data-flow/map-query-parameters-to-variables-in-a-data-flow-component?view=sql-server-2017
Also, the "Oracle Provider for OLE DB" behaves differently than the "Microsoft OLE DB Provider for Oracle", so it depends which you are using.
I am trying to get status based to totalamount field.For that I need to use CASE statement like this :
Select TotalAmt,CASE WHEN 'TotalAmt' = '0' THEN 'Open' ELSE NULL END AS status from Invoice
I have checked the syntax too,it's correct.But still I am getting query Parser error
Intuit's flavor of SQL (which is a very limited, slightly non-SQL-standard dialect of SQL) does not support CASE statements.
You can't do what you're trying to do, as it's unsupported.
I have a simple query which states
convert(decimal(20,10),a.sumclk)/ nullif(convert(decimal(20,10),a.sumimp),0) as CTR1
When I run this I get a message saying 'Data Type "sumclk" does not match a Defined Type name.'
I looked around for what this means but I'm stuck
I'm using Teradata
Instead of convert(decimal(20,10),a.sumclk) (which is MSSQL), try CAST(a.sumclk as decimal(20,10)) (which I found on the Teradata forums: http://forums.teradata.com/forum/database/explicit-casting)
I am having an issue with SSRS 2005. I have a case statement that that works fine in other queries and reports, but errors on the latest report for some reason. I don't believe its an issue with the query rather an issue with reporting services. The error I get is "Query execution failed for data set, invalid column name 'Status'.Has anyone else run into this issue? how did you resolve? The code is below just in case
SELECT Task
, Account_Num
, CASE WHEN DATEDIFF(dd,GETDATE(),Due_Date) < 0
THEN 'Overdue'
WHEN DATEDIFF(dd,GETDATE(),Due_Date) < 3
THEN 'Alert'
ELSE 'Okay'
END AS Status
FROM MyDb
Try square brackets around the reserved word [status]
Sometimes this is due to using an alias. Sometimes, one is not allowed to use the alias and must type out the fully-qualified name.
ourDatabase.ourTable.ourColumnName
This may or may not apply to the OP's situation, however. I have not tried it with the Case statement.