时间:2021-07-01 10:21:17 帮助过:2人阅读
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
insert spt_values ( name ,number ,type ,low ,high ,status) values ( null ,0 , ‘P ‘ ,1 ,0x00000001 ,0)
insert spt_values ( name ,number ,type ,low ,high ,status) values ( null ,1 , ‘P ‘ ,1 ,0x00000002 ,0)
insert spt_values ( name ,number ,type ,low ,high ,status) values ( null ,2 , ‘P ‘ ,1 ,0x00000004 ,0)
insert spt_values ( name ,number ,type ,low ,high ,status) values ( null ,3 , ‘P ‘ ,1 ,0x00000008 ,0)
insert spt_values ( name ,number ,type ,low ,high ,status) values ( null ,4 , ‘P ‘ ,1 ,0x00000010 ,0)
insert spt_values ( name ,number ,type ,low ,high ,status) values ( null ,5 , ‘P ‘ ,1 ,0x00000020 ,0)
insert spt_values ( name ,number ,type ,low ,high ,status) values ( null ,6 , ‘P ‘ ,1 ,0x00000040 ,0)
insert spt_values ( name ,number ,type ,low ,high ,status) values ( null ,7 , ‘P ‘ ,1 ,0x00000080 ,0)
go
-- ‘P ‘ continued....
declare
@number_track integer
,@char_number_track varchar (12)
select @number_track = 7
select @char_number_track = convert ( varchar ,@number_track)
-- max columns is 1024 so we need 1024 bit position rows;
-- we‘ll actually insert entries for more than that
while @number_track < 1024
begin
raiserror(‘type= ‘‘ P ‘‘ ,@number_track=%d ‘ ,0,1 ,@number_track)
EXECUTE(
‘
insert spt_values ( name ,number ,type ,low ,high ,status)
select
null
,( select max (c_val.number)
from spt_values c_val
where c_val.type = ‘‘ P ‘‘
and c_val.number between 0 and ‘ + @char_number_track + ‘
)
+ a_val.number + 1
, ‘‘ P ‘‘
,( select max (b_val.low)
from spt_values b_val
where b_val.type = ‘‘ P ‘‘
and b_val.number between 0 and ‘ + @char_number_track + ‘
)
+ 1 + (a_val.number / 8)
,a_val.high
,0
from
spt_values a_val
where
a_val.type = ‘‘ P ‘‘
and a_val.number between 0 and ‘ + @char_number_track + ‘
‘)
select @number_track = ((@number_track + 1) * 2) - 1
select @char_number_track = convert ( varchar ,@number_track)
end --loop
go
|
select number from master..spt_values with(nolock) where type=‘P‘ /**解释:master..spt_values表的字段值为P的对应number字段值是从0-2047*/
select MONTH(convert(varchar(10), dateadd(MONTH, number - 1,
DATEADD(yy,DATEDIFF(yy,0,getdate()),0)), 120)) as yue from master.dbo.spt_values WHERE
type=‘P‘ AND number <= datediff(MONTH, DATEADD(yy,DATEDIFF(yy,0,getdate()),0),
dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate())+1,0)) ) + 1 AND number>0
select * from master.dbo.spt_values where type=‘p‘
select number from master..spt_values with(nolock) where type=‘P‘
学习使用master.dbo.spt_values表
标签:ack server for erro sql with 它的 文件 pac