sql data type error when dividing two figures - sql

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)

Related

How to pass a Date Pipeline Parameter to a Data Flow use in a Dataflow Expression Builder

I am doing something that seems like it should be very easy yet I have yet to figure this out. I have read countless posts and tried everything I can think of and still no success.
Here goes:
I created a Pipeline Parameter pplLastWritten with a default value of 2022-08-20 12:19:08 (I have tried without the time for troubleshooting and still get errors)
Then I create a Data Flow Parameter ptblTableName
I have tried to convert to a Date, keeping as is and converting later...you name it still errors out.
In the expression builder I tried this and many more ways to build out to a sql statement:
"SELECT * FROM xxxxxx."+$ptblTableName+"where Lastwritten>='{$ptblLastWritten}'"
This is the post I got the idea from: ADF data flow concat expression with single quote
This is the error I got most of the time.
Operation on target df_DynamicSelect failed: {"StatusCode":"DF-Executor-StoreIsNotDefined","Message":"Job failed due to reason: at Source 'RptDBTEST'(Line 5/Col 0): The store configuration is not defined. This error is potentially caused by invalid parameter assignment in the pipeline.","Details":""}
I have tried so many things but in the end nothing has worked. I am new to Data Factory and come from the SSIS world which was so much easier. I would greatly appreciate someone helping. Please explain this like I'm a kindergartener because this tool is making me feel like it. :) Thank you in advanced.
I have tried various ways to format
Using different ideas in the expression builder
the ideas in this post: ADF data flow concat expression with single quote
You can use concat() function in the Data flow dynamic expression like below.
Here is the sample data in SQL.
I have created two dataflow parameters mytable and mydate.
Passed the values like below. Check the expression checkbox. For date you can also pass like this '2022-11-07T00:00:00.0000000'.
In the Query option use below Expression.
concat('select * from dbo.',$table_name,' where mydate >=','\'',$mydate,'\'')
Values inserted in Target table.

exporting the data gives error when the type is 'smalldatetime' and value is null

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.

Google BigQuery: Error: Invalid schema update. Field has changed mode from REQUIRED to NULLABLE

I'm trying to append the results of a query to another table.
It doesn't work and sends out the following error:
Error: Invalid schema update. Field X has changed mode from REQUIRED to NULLABLE.
The field X is indeed REQUIRED, but I don't try to insert any NULL-values into that specific column (the whole table doesn't have a single NULL value).
This looks like a bug to me. Anyone knows a way to work around this issue?
The issue is fixed after switching from Legacy SQL to Standard SQL.

Oracle math functions

I am trying to get a rounded value in Oracle (using SQL Developer) through following statement:
ROUND((1-POWER((SUM(D.PFY/100*E.OUT_8_)/SUM(E,OUT_8_)), (1/(SUM(PHOTO*E.OUT_8_)/SUM(E.OUT_8_)))))*1000000, 0) AS PFYPPM
However, I am getting an error as:
invalid number of arguments.
What is it that I am doing wrong?
Sometimes Oracle error messages are actually helpful.
invalid number of arguments
Check your function calls.
sum() takes only one argument.
SUM(E,OUT_8_)
should probably be
SUM(E.OUT_8_)

SSIS getdate into DateTimeOffset column - data value overflowed the type

I have an SSIS package. The source is a SQL query. The destination is a table. The package worked until I changed a column in a destination table from datetime to datetimeoffset(0).
Now, all records fail with a "Conversion failed because the data value overflowed the type used by the provider" error on this particular column.
The value in the source query is getdate(). I tried TODATETIMEOFFSET(getdate(),'-05:00') without success.
In fact, the only thing that has worked so far is to hard code the following into the source query:
cast('3/14/12' as datetime)
The only other interesting piece of information is that the package worked fine when running the source query against another server implying that maybe a setting is involved - but I see no obvious differences between the two servers.
I was going to suggest to add a "data conversion component" to deal with it, but since you changed only on the destination, it means that you can change your source query to do:
select cast(YOUR_DATE_COLUMN as datetimeoffset(0))
In case anyone else is looking, we found an alternative solution that works if the source is in SQL 2005 (no support for datetimeoffset).
select dateAdd(minute,datediff(minute,0,getutcdate()),0)
The intent is to reduce the precision. Granted I also lose seconds but if I try the above line with seconds I get an overflow error.