不使用存储过程,执行insert语句,如果内容超长,自动截断。

解决方案 »

  1.   

    插入的时候,使用left处理一下。
      

  2.   

    insert语句很长? 不会截断啊
      

  3.   

    在insert,update触发器中,用left或substring可以截断指定长度外的字符
      

  4.   

    用 len 获取列长度,left取截断数据
      

  5.   

    create table tb_1
    (
    id int,
    ch char(10)
    )godeclare @is_str char(20)
    declare @is_len int
    set @is_str ='12345467890123456789'select @is_len=length from syscolumns where object_id('tb_1') =id and name ='ch'insert tb_1(id,ch)
    select      2,left(@is_str,@is_len) select * from tb_1如用len或datalength取长度时,如表为空行,其取值将为NULL
      

  6.   

    --查询表栏位的类型和长度
    select c.name '表名',a.name '栏位名',b.name '类型',a.length '长度' from syscolumns a
    inner join systypes b on a.xtype = b.xtype 
    left join sysobjects c on a.id = c.id and c.xtype = 'U'
    where c.name = 'tablename'再根据"长度"用left函数来截取栏的值!
      

  7.   

    刚用楼上两位的方法,请问为什么nvarchar查出来的长度是数据库中定义的两倍呢?
      

  8.   

    nvarcar存储的是UNIOCDE字符,每个字符占2个字节。varchar每个英文字符占1个字节。