把今年所有的周六周日都插入一张表里
2017-03-17 14:33
190 查看
declare @datetime datetime,@weekday char(6)
set @datetime='2017-1-1'
while @datetime<='2017-12-31'
begin
select @weekday=datename(weekday,@datetime)
if @weekday='星期六' insert bas_Holiday([HolidayTime]) values(@datetime)
if @weekday='星期日' insert bas_Holiday([HolidayTime]) values(@datetime)
select @datetime=dateadd(day,1,@datetime)
end
go
select * from bas_Holiday;
set @datetime='2017-1-1'
while @datetime<='2017-12-31'
begin
select @weekday=datename(weekday,@datetime)
if @weekday='星期六' insert bas_Holiday([HolidayTime]) values(@datetime)
if @weekday='星期日' insert bas_Holiday([HolidayTime]) values(@datetime)
select @datetime=dateadd(day,1,@datetime)
end
go
select * from bas_Holiday;
相关文章推荐
- SQL数据库中把一张表从一个数据库中插入到另外一个数据库的一张表里
- mysql把一张表里的数据插入到另一张表里
- mysql 如何用一条SQL将一张表里的数据插入到另一张表 3个例子
- SQL 把一个数据库里面的某张表里的数据插入到另外一个数据库里面的一张表
- JDBC远程从一个MySql数据库中的一张表里面读出数据(这个数据库需要用SSH隧道连接,大约8W条数据),然后分别插入到另一个数据库中的两张表里
- oracle中从4个表查询数据并插入到另一张表里 扩展到查询到的数据和其他数据共同插入
- 从一张表里插入到另一张表
- SQL数据库中把一张表从一个数据库中插入到另外一个数据库的一张表里
- mysql插入一张表里的数据到另一张表
- SQL取出 所有周六 周日的日期
- mysql 如何用一条SQL将一张表里的数据插入到另一张表
- SQL取出 所有周六 周日的日期
- mysql 如何用一条SQL将一张表里的数据插入到另一张表 3个例子
- SQL中在日期范围内判断星期几,把周六、周日的日期插入表
- sql 查出两个时间段内所有的工作日时间[去除周六周日]
- 将一数据库中的所有自己建的表的字段融合到一张大表里
- MySQL如何用一条SQL将一张表里的数据插入到另一张表
- SQL中将一张表里的信息对应插入到另一张表中
- SQL取出 所有周六 周日的日期
- SQL取出 所有周六 周日的日期