select * from his_domain where type='cn' and len(domain)=3 and domain not like'%[0-9]%' and domain not like'%-%' SELECT * into inf_domain FROM inf_domain20150914 WHERE 1=2 ALTER TABLE inf_domain ADD CONSTRAINT PK_inf_domain PRIMARY KEY (id) select * from inf_domain where len(domain)=3 and domain not like'%-%' select * from inf_domain where domain like'%azun%' select * from inf_domain where domain='zzzzz' select convert(varchar(10),dateadd(d,-6,getdate()),112) select * from his_domain select count(*) from his_domain --declare @sql varchar(500) --set @sql='insert into his_domain select domain,type,length,dtDelete,dtCreate,isRegister from inf_domain'+convert(varchar(10),dateadd(d,-5,getdate()),112)+';drop table inf_domain'+convert(varchar(10),dateadd(d,-5,getdate()),112) --exec(@sql) select count(*) from sysobjects where name='inf_domain'+convert(varchar(10),getdate(),112) and type='U' select count(*) from inf_domain20150918
返回跨两个指定日期的日期边界数和时间边界数。
DateADD 语法:
DateAdd ( datepart , numb , date )
Datepart:指定参于运算的日期部分
Numb:需要加减的数值,numb与date相加减结果为函数的值,如果numb为负则进行减
Date:参于运算的日期
DATEDIFF语法:
DATEDIFF ( datepart , startdate , enddate )
Datepart:参于运算的日期部分
Startdate:开始日期(从结束日期里减去)
Enddate:结束日期
结束日期减去开始日期就是函数的值 备注 enddate 减去 startdate。如果 startdate 晚于 enddate,则返回负值。 datepart 参数
year | yy, yyyy |
quarter | qq, q |
month | mm, m |
dayofyear | dy, y |
day | dd, d |
week | wk, ww |
Hour | hh |
minute | mi, n |
second | ss, s |
millisecond |
例: SELECT DATEDIFF ( month , '2008-1-1‘ , '2008-7-10' )