Joining Columns

  • I have two columns same db, different tables, one is varchar( S 12345) and the other is int (12345).

    I want to join the tables using these columns I don't need to used the (S)

    Is there a way to do this if so how can it be done.

    Joining the tables I get an error Syntax error converting the varchar value 's 12345' to a column of data type int.

    Thanks

  • You should convert these to the same data type to join them. Ideally they would be, and you will lose some indexing benefits if they are not.

    You could use a SUBSTRING command to strip out the number from the varchar field, and then a CAST to convert it to an INT.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply