数据插入,在插入的的字符串前增加指定的字符,且字段位数不变
如productInfo表
ID  productID ...
1     A001
2     A002
.      .
.      .
.      .
10    A010     (不是A0010)就这样,请大虾们指点一下

解决方案 »

  1.   

    Select '10 '+ A010 From table这样 ?
      

  2.   

    Select '10 '+ productID From productInfo
      

  3.   

    先select出数据表中最大的productID,这应该很容易吧?然后做相应处理,再insert进去。比如最大的是A015,取出后取子串,得到015,转换成整型得到15,加上1后ToString("D3"),的到016,再连接A得到A016,最后插入数据表。关键语句:
    select max(productID) from productInfo
    string result=(int.Parse(str.SubString(1,3))+1).ToString("D3");
    result="A"+result;
    插入。