易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL日历表数据的简单生成

为了公司考勤系统的需要
编写的几个简单存储过程(可以手动运行,也可以设置事务自动运行!感觉还行比较通用,写出来共享下)
Calendar表结构很简单,2个字段:
fdDate 日期
fdType 考勤类型(工作日N,周末W,节假日H[需要根据需要自己修改])
--判断一段时间范围内的工作日(N)和周末(W)
Create     PROCEDURE [dbo].[NewMonthWeekDay_Calendar]
@sdate smalldatetime,
@edate smalldatetime
AS
declare @fdDate smalldatetime
declare @WeekDay varchar(20)
declare cr0 cursor for
 select fdDate from calendar where fddate>=@sdate and fddate<=@edate
open cr0
fetch next from cr0 into @fdDate
 while @@fetch_status=0
 begin
  if (datename(weekday,@fdDate)='星期一')
   update calendar set fdType='N' where fdDate=@fdDate
  if (datename(weekday,@fdDate)='星期二')
   update calendar set fdType='N' where fdDate=@fdDate
  if (datename(weekday,@fdDate)='星期三')
   update calendar set fdType='N' where fdDate=@fdDate
  if (datename(weekday,@fdDate)='星期四')
   update calendar set fdType='N' where fdDate=@fdDate
  if (datename(weekday,@fdDate)='星期五')
   update calendar set fdType='N' where fdDate=@fdDate
  if (datename(weekday,@fdDate)='星期六')
   update calendar set fdType='W' where fdDate=@fdDate
  if (datename(weekday,@fdDate)='星期日')
   update calendar set fdType='W' where fdDate=@fdDate
  
  fetch next from cr0 into @fdDate
 end
close cr0
deallocate cr0 
--根据年和月自动插入Calendar表新日期数据
Create    PROCEDURE [dbo].[NewMonth_Calendar]
@Year int,
@Month int
AS
 Select TOP 50 ID = Identity(Int, 0, 1) Into #T from SysColumns
 insert into cas..calendar(fdDate)
 Select Convert(Varchar(10), DateAdd(dd, ID, Cast(Rtrim(@Year) + '-' + Rtrim(@Month) + '-' + '01' As DateTime)), 120) from #T
 W


相关文档:

SQL时间函数

--日期转换参数,值得收藏
select CONVERT(varchar, getdate(), 120 )2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')20040912110608
select CONVERT(varchar(12) , getdate(), 111 )2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )20040912 ......

BuildQuery A Simple SQL Query Tool

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BuildQuery
{
/// <summary>
/// 使用提供的数据建立一个SQL查询
/// </summary>
public class BuildQuery
{
#region 类的变量
int numFieldsCount, ......

LINQ to SQL 性能 10 Tips


LINQ to SQL 性能 10 Tips
http://www.cnblogs.com/worksguo/archive/2008/06/04/1213075.html
前一周,我的硬盘有两分区坏了,我准备的文章与资料都在里面,所以LINQ的文章停了一段时间,真的太不好拉,为来弥补一下就先发这篇文章上拉,明天再一篇关于Disconnection Data的文章。
只不过幸好,在这几天中我竭尽全力 ......

Sql版本除去html并截取指定长度的字符串

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
Go
----截取字符串,并出去html
create FUNCTION [dbo].[CutString] (@str varchar(1000),@length int) 
RETURNS varchar(1000) AS 
BEGIN
 declare @mainstr varchar(1000)
 declare @substr varchar(1000)
 if(@str is not null or @st ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号