Jump to content

Can someone point out what is wrong with this cast statement?


bbenedict

Recommended Posts

Need to convert some columns to different data type, but this statement will not work. Any idea what I am missing? (mgmt Studio has the first 'CAST' and 'AS' underlined. SELECT CAST [ETL_ID as int] as ETL_ID, NAMEX, DU_DEGREE_STATUS, DU_ESTS_DESC, Cast [bANNER_ID as (varchar(36),Null)]as BANNER_ID, DU_COLLEGE_DESC, cAST [DU_DEL_TERM_CODE_ADMIT as (VARCHAR(255),NULL)] AS DU_DEL_TERM_CODE_ADMIT, AGE, ETHNICITY_DESCRIPTION, GENDER, cAST [T1 as (VARCHAR(255),NULL)] AS T1, T1Status, cAST [T2 as (VARCHAR(255),NULL)] as T2, T2Status, cAST [T3 as (VARCHAR(255),NULL)] as T3, T3Status, cAST [T4 as (VARCHAR(255),NULL)] as T4, T4StatusFROM dbo.['Tracking 3$']

Link to comment
Share on other sites

  • 3 weeks later...

Thanks! So i got this to work but there is still one wierd problem, when the cast statement is executed the values in one of the colums goes through this transformation: original (float, null) - 12594570New (after: CAST(thing_ID AS VARCHAR(36)) AS Thing_ID) 1.25946e+007 In the warehouse I cannot link these notations with the fact table.

Link to comment
Share on other sites

Update: I inserted ,Cast(CAST(BANNER_ID AS VARCHAR(50))as decimal) as BANNER_ID to try and fix the notication and return it back to a simple number and now I get this 'Error converting data type varchar to numeric." so i think i am getting closer.

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...