Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a doubt that when i am using CAST function in DIRECT QUERY..it's not working.
EX:->
DIRECT QUERY
SELECT
a.code_marketing_campaign
,b.[BusinessUnit__c] as 'Parent Campaign BU'
,b.[CurrencyIsoCode] as ' Parent Campaign Currency Code'
,CAST(b.[Description]) as 'Parent Campaign Description'
,CAST(b.category_marketing_campaign ) as 'Parent Campaign Type'
from (select distinct code_marketing_campaign from [WH_ID_EMEA].[dwh].[marketing_campaign]) a
inner join [WH_ID_EMEA].[dwh].[marketing_campaign] b
on a.code_marketing_campaign=b.bkey_marketing_campaign
group by
a.code_marketing_campaign
,b.[BusinessUnit__c]
,b.[CurrencyIsoCode]
,CAST(b.[Description])
,CAST(b.category_marketing_campaign );
Please suggest..
Hello, if you are trying to use cast just to rename a column you should just use AS, for example
SELECT
a.code_marketing_campaign
,b.[BusinessUnit__c] as 'Parent Campaign BU'
,b.[CurrencyIsoCode] as ' Parent Campaign Currency Code'
,b.[Description] as 'Parent Campaign Description'
,b.category_marketing_campaign as 'Parent Campaign Type'
If you are trying to change the data type you have to specify the data type, like this
SELECT
a.code_marketing_campaign
,b.[BusinessUnit__c] as 'Parent Campaign BU'
,b.[CurrencyIsoCode] as ' Parent Campaign Currency Code'
,CAST(b.[Description] as varchar(30)) as 'Parent Campaign Description'
,CAST(b.category_marketing_campaign as int) as 'Parent Campaign Type'
Hope that helps!