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
Ïà¹ØÎĵµ£º
--ÈÕÆÚת»»²ÎÊý,ÖµµÃÊÕ²Ø
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 ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BuildQuery
{
/// <summary>
/// ʹÓÃÌṩµÄÊý¾Ý½¨Á¢Ò»¸öSQL²éѯ
/// </summary>
public class BuildQuery
{
#region ÀàµÄ±äÁ¿
int numFieldsCount, ......
use myoa
select * from
delete from department where departmentid=1
insert Department(DepartmentId,DepartmentName) values(1,'¼¼Êõ²¿')
update Department set departmentname='ÐÅÏ¢¼¼Êõ²¿' where departmentid=1
--ɾ³ý±í
drop table department
--ɾ³ýÊý¾Ý¿â
drop database bai
--ͳ¼ÆÊý¾Ý¿â±íÖмǼ
se ......
ÔÚLINQ to EntitiesÖÐûÓа취ÔÙÏñ LINQ to SQL ÖÐÒ»ÑùʹÓà Contains µÄ·½·¨À´ÊµÏÖsql "in" ¹Ø¼ü×Ö
ÏÂÃæ´úÂëÔÚ LINQ to SQL ÖпÉÐÐ ÔÚLINQ to EntitiesÈ´ÎÞ·¨ÔËÐУº
var s = db.Account.Select(c => c.ID);
var ret =(from t in db.Profile
where&n ......
ÈÕÖ¾ÎļþÂú¶øÔì³ÉSQLÊý¾Ý¿âÎÞ·¨Ð´ÈëÎļþʱ£¬¿ÉÓÃÁ½ÖÖ·½·¨£º
¡¡¡¡Ò»ÖÖ·½·¨£ºÇå¿ÕÈÕÖ¾¡£
¡¡¡¡1£®´ò¿ª²éѯ·ÖÎöÆ÷£¬ÊäÈëÃüÁî
¡¡¡¡DUMP TRANSACTION Êý¾Ý¿âÃû WITH NO_LOG
¡¡¡¡2.ÔÙ´ò¿ªÆóÒµ¹ÜÀíÆ÷--ÓÒ¼üÄãҪѹËõµÄÊý¾Ý¿â--ËùÓÐÈÎÎñ--ÊÕËõÊý¾Ý¿â--ÊÕËõÎļþ--Ñ¡ÔñÈÕÖ¾Îļþ--ÔÚÊÕËõ·½Ê½ÀïÑ¡ÔñÊÕËõÖÁXXM,ÕâÀï»á¸ø³öÒ»¸öÔÊÐíÊÕËõµ ......