譬如一张两个字段的表:第一个字段是编号,第二个是名称。现在假如希望插入1000条数据,编号为数字不能重复(例如1——1000),名称可以重复,例如从“张三,李四”选择插入。
请问应该怎样写sql语句?谢谢!
请问应该怎样写sql语句?谢谢!
解决方案 »
- sql server 2005安装过程中为什么只能选择联机丛书
- SQL SERVER 取前十条记录的问题
- sql server2008如何注册?
- T-SQL事务处理的问题
- 修改系统服务sql server agent 的登陆用户
- 一张报表连接多个数据源是出现的问题?
- 紧急求助一个sql存储过程问题
- 数据库匹配大小写的问题,请教!
- 我创建在视图上的instead of update怎么不管用?激发不了啊。
- 寻求最好的ORACLE书籍
- 一个SQL server2000的小问题
- 关于一个统计语句!/*************************标题要长**************************/
if not object_id('tb1') is null
drop table tb1
Go
Create table tb1([id] int identity,[numb] int)
Insert tb1
select 20 union all
select 30 union all
select 50 select * from tb1
/*
id numb
----------- -----------
1 20
2 30
3 50(3 行受影响)
*/
drop table tb1
set @s='张三,李四,jinjazz'
insert into t(name)
select replace(reverse((left(s,charindex(',',s)))),',','') as S from(
select r,reverse(left(@s,r))+',' as s
from(
select (select count(*) from sysobjects where name<=t.name ) as r
from sysobjects t
)a where r<=len(@s)
and left(@s+',',r+1) like '%,'
)t order by rselect * from t
drop table t/*
(3 行受影响)
id name
----------- ----------------------------------------------------------------------------------------------------
1 张三
2 李四
3 jinjazz(3 行受影响)
*/