Sql 字符递增的问题 - MS-SQL Server / 基础类
现在有一张表 A 两个字段id varchar(10),name varchar(10) id列里的值为0001,0002,0003,...0010 我想将id列设为递增 请问怎么解决
引用 现在有一张表 A 两个字段id varchar(10),name varchar(10) id列里的值为0001,0002,0003,...0010 我想将id列设为递增 请问怎么解决 SQL code: Id, FormatId, F1 ,F2 Id序号我设了自动加一,FormatId我想他也象这样"SL000001", 当Insert时就加1,FormatId我想他也能自动加一"SL000001","SL000002"... 能用一条sql什么办法实现.最好不要用中间表。有什么好方法? 谢谢! create table #test (id int identity, FormatId as 'SL'+right(10000000+id,6), F1 varchar(50)) go insert #test(F1) select '1' union all select '2' select * from #test drop table #test /* id FormatId F1 ----------- -------------- ----- 1 SL000001 1 2 SL000002 2 (所影响的行数为 2 行) */ SQL code: create table tb(tid int identity,id as right(10000+tid,4),f int) go insert into tb(f) values(1) select * from tb /* tid id f ----------- -------- ----------- 1 0001 1 (所影响的行数为 1 行) */ insert into t
相关问答:
执行的顺序: 1)文件浏览框(选择文件使用) 选择好文件后 点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下 2)读取这个文件夹下的csv的文件,转换成sql 3 ......
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jas ......
可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......
我想查询出每天数据的最大的一个值。表的格式如下 表名: hisdata 字段 编号 值 状态 时间 Id value state dattime 101 32.3 0 ......
运行后报错误如下: 错误类型: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 '数学 + 4where 姓名='王静'' 中。 ......