data conversion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chongo1
    New Member
    • May 2014
    • 1

    data conversion

    hi guys i have an sql query that alters a view by changing the data type of a column from varchar to int but keeps giving me this error "Conversion failed when converting the varchar value 'File N' to data type int." here is the sql query
    Code:
    ALTER VIEW V_IMPORT_RECORDS
    AS 
    SELECT
    case when cast(left(right(IMPORT_RECORDS.whichfile,44),6)as integer) = '010182' then 'RD100'
    when cast(left(right(IMPORT_RECORDS.whichfile,44),6)as integer) = '010181' then 'RD99' else 0 end as 'MachineName'
    FROM Import_Records
    Last edited by Rabbit; May 7 '14, 03:48 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data.

    You are getting that error because you are trying to convert the string 'File N' to a number, which is impossible.

    Comment

    Working...