日期:2014-05-17  浏览次数:20467 次

用sql语句创建一个全是三十六进制数的表,从001到zzz
用sql语句创建一个全是三十六进制数的表,要求从001到zzz
------最佳解决方案--------------------
修改
select rtrim(char(number+48)) a into #tb from dbo.spt_values where type='P' and number<10
union all
select char(number+97) from dbo.spt_values where type='p' and number<26

select a.a+b.a+c.a from #tb a,#tb b,#tb c where a.a+b.a+c.a>'000'
order by 1

drop table #tb

/*
----
001
002
003
004
005
006
....
zzw
zzx
zzy
zzz

(46655 row(s) affected)

------其他解决方案--------------------
是这个表某列的内容从001到zzz?
------其他解决方案--------------------
select rtrim(char(number+48)) a into #tb from dbo.spt_values where type='P' and number<10
union all
select char(number+97) from dbo.spt_values where type='p' and number<26

select a.a+b.a+c.a from #tb a,#tb b,#tb c where ascii(c.a)>48
order by 1

drop table #tb

/*
----
001
002
003
004
005
006
....
zzw
zzx
zzy
zzz

(45360 row(s) affected)

------其他解决方案--------------------
引用:
是这个表某列的内容从001到zzz?

是这个表的内容只有这些
------其他解决方案--------------------
那就是创建表的时候每个列都要加约束,或插数据的时候用触发器来限制数据
------其他解决方案--------------------
引用:
修改SQL code123456789101112131415161718192021222324select rtrim(char(number+48)) a into #tb from dbo.spt_values where type='P' and number<10union allselect char(number+97) from dbo.spt_valu……

请问dbo.spt_values是什么
------其他解决方案--------------------
引用:
引用:修改SQL code123456789101112131415161718192021222324select rtrim(char(number+48)) a into #tb from dbo.spt_values where type='P' and number<10union allselect char(number+97……

master..spt_values,系统表
------其他解决方案--------------------
引用:
引用:引用:修改SQL code123456789101112131415161718192021222324select rtrim(char(number+48)) a into #tb from dbo.spt_values where type='P' and number<10union allsele……

select * into table1.int_id from table2.id,table1和table2分别在两个数据库中,现在table2数据库名称中有.,现在这句sql总是报错,说。附近有语法错误,请问有什么解决办法吗