data type convertion error.

  • Tabe-A

    A-d-int,pk,notnull

    A_H--nvarchar(10),null

    A_dn-navrchar

    A-S-int,null

    A_c-date(smalldatetime,null

    Table-B,

    B_d --int(PK,not null)

    B_H---int,notnull,

    B_Dn---nvarchar(14),notnull)

    B_c_date--(smalldatetime,null)

    B-si--(int,null)

    B_DT--(smalldatetime,null)

    We have a varchar column(table-A) which need to be insert to Int coulmn(tabel B),

    We have used convertion but it is not working as the column in Table A is having Char Data.

    such as "D" eg: D301510677.

    SO we need to remove that D or trucate the D and need to insert only Numeric values into TABLE -B

    Can any one help me in below query how to split the "D" or trucate it and How can i insert only NUMERIC Values into the table-B.

    and Please let me know the SYantax which i have to add in the below query.

    Here i need to trucate the A_H column from A table.

    Insert into Table-B

    (B_h, B_Dn, B_S, B_C_Date,B_dt)

    (select A_H, A_DN,table- A_S, A_c_date, substring(A_DN, 3, 8)

    from tabel-A

    where A.A_dn + str(A.A_H) NOT in

    (select B_DN + str(B_H) from B))

    Please guide me

    Many THanks

  • duplicate post

    reply to this thread

    http://www.sqlservercentral.com/Forums/Topic1322306-392-1.aspx#bm1326782

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

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