惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
罗磊的独立博客
月光博客
月光博客
GbyAI
GbyAI
腾讯CDC
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
雷峰网
雷峰网
B
Blog RSS Feed
美团技术团队
M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
D
Docker

博客园 - roboth

转:“由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值”的解决方法 .net tostring format格式说明 - roboth 一、DIP简介(DIP--Dependency Inversion Principle): 请确认 &lt;Import&gt; 声明中的路径正确,且磁盘上存在该文件。 异步委托 Visual Studio 最常用的13个快捷键 H1N1:速饮配方 通过注册表获取文件的ContentType [转]解决ASP.NET Web Applicatio超时时间已到.在操作完成之前超时时间已过或服务器未响应 - roboth 在线创建pdf msdn之sp_xml_preparedocument Route命令使用详解 电子书下载 买药记 抓取图片 xslt之<xsl:apply-templates - roboth - 博客园 盲人摸象 dom操作时机 js小技巧之访问元素属性
sql产生日历表
roboth · 2009-05-15 · via 博客园 - roboth


CREATE TABLE [dbo].[time_dimension] ( 
   
[time_id] [int] IDENTITY (11NOT NULL , 
   
[the_date] [datetime] NULL , 
   
[the_day] [nvarchar] (15NULL , 
   
[the_month] [nvarchar] (15NULL , 
   
[the_year] [smallint] NULL , 
   
[day_of_month] [smallint] NULL , 
   
[week_of_year] [smallint] NULL , 
   
[month_of_year] [smallint] NULL , 
   
[quarter] [nvarchar] (2NULL , 
   
[fiscal_period] [nvarchar] (20NULL 
ON [PRIMARY] DECLARE @WeekString varchar(12), 
@dDate SMALLDATETIME
@sMonth varchar(20), 
@iYear smallint
@iDayOfMonth smallint
@iWeekOfYear smallint
@iMonthOfYear smallint
@sQuarter varchar(2), 
@sSQL varchar(100), 
@adddays int 
   
SELECT @adddays = 1 --日期增量(可以自由设定) 
SELECT @dDate = '01/01/2002' --开始日期 
   
WHILE @dDate < '12/31/2009'  --结束日期 
BEGIN 
   
   
SELECT @WeekString = DATENAME (dw, @dDate
   
SELECT @sMonth=DATENAME(mm,@dDate
   
SELECT @iYear= DATENAME (yy, @dDate
   
SELECT @iDayOfMonth=DATENAME (dd, @dDate
   
SELECT @iWeekOfYear= DATENAME (week, @dDate
   
SELECT @iMonthOfYear=DATEPART(month@dDate
   
SELECT @sQuarter = 'Q' +  CAST(DATENAME (quarter, @dDate)as varchar(1)) 
   
INSERT INTO time_dimension(the_date, the_day, the_month, the_year, 
   day_of_month, 
   week_of_year, month_of_year, quarter) 
VALUES 
   (
@dDate@WeekString@sMonth@iYear@iDayOfMonth@iWeekOfYear
   
@iMonthOfYear@sQuarter
   
SELECT @dDate = @dDate + @adddays 
END 
GO 
select * from