Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    1

    Unanswered: Allowing truncation of data on insert

    I am using SQL 2000. Is there a DB option that will allow an insert to successfully complete even though the data will be truncated in some of the fields?

  2. #2
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    try this...

    Code:
    set ansi_warnings off
    create table #tmp(f1 varchar(1))
    insert into #tmp values ('!')
    insert into #tmp values ('!!')
    select * from #tmp
    drop table #tmp
    go
    set ansi_warnings on
    create table #tmp(f1 varchar(1))
    insert into #tmp values ('!')
    insert into #tmp values ('!!')
    select * from #tmp
    drop table #tmp
    go
    Paul Young
    (Knowledge is power! Get some!)

  3. #3
    Join Date
    Jan 2003
    Posts
    3
    Another approach is to ensure the data is truncated when you insert it by explicitly truncating it yourself.

    Eg INSERT INTO myTable (myColName)
    VALUES(CAST('abcdefg' AS varchar(4)))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •