易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关问答:

SQL如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

sql - MS-SQL Server / 疑难问题

sql的软件在哪里可以下啊!在网上找了蛮多都用不了啊

随便搞一D版吧,

迅雷第一个就可以用
2000,2005都这样

http://119.147.41.16/down?cid=0698C2D64D7D637D90A6D2482298E6717D4F15CD&t=2&fmt=-1 ......

SQL server分解XML - MS-SQL Server / 应用实例

下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......

关于Vb中sql语句的写法(100分) - Java / Web 开发

求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号