¡¾SQL SERVERÖÐһЩÌرðµØ·½µÄÌرð½â·¨2¡¿
/*----------------------------------------------------------------
-- Author :feixianxxx(poofly)
-- Date :2010-04-20 20:10:41
-- Version:
-- Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86)
Mar 29 2009 10:27:29
Copyright (c) 1988-2008 Microsoft Corporation
Enterprise Evaluation Edition on Windows NT 6.1 <X86> (Build 7600: )
-- CONTENT£ºSQL SERVERÖÐһЩÌرðµØ·½µÄÌرð½â·¨
----------------------------------------------------------------*/
--1.¹ØÓÚwhereɸѡÆ÷ÖгöÏÖÖ¸¶¨ÐÇÆÚ¼¸µÄÇó½â
--»·¾³
create table test_1
(
id int,
value varchar(10),
t_time datetime
)
insert test_1
select 1,'a','2009-04-19' union
select 2,'b','2009-04-20' union
select 3,'c','2009-04-21' union
select 4,'d','2009-04-22' union
select 5,'e','2009-04-23' union
select 6,'f','2009-04-24' union
select 7,'g','2009-04-25'
go
ÎÒÃÇÒ»°ãͨ¹ý datepart(weekday )½øÐÐÇó½â£¬±ÈÈçÇó½âÐÇÆڵļǼ
select * from test_1
where DATEPART(WEEKDAY,t_time+@@DATEFIRST-1)=2
/*
id value t_time
----------- ---------- -----------------------
3 c 2009-04-21 00:00:00.000
*/
ÕâÀïÉæ¼°µ½ @@datefirst Õâ¸öϵͳ±äÁ¿£¬Ò»°ãÎÒÃÇÓÃÀ´µ÷½Ú²»Í¬µØ·½µÄÈÕÆÚÏ°¹ß¡£
Èç¹ûÄã¾õµÃ¹ØÓÚÕâ¸ö±äÁ¿ºÜÄÑÒ²ÀÁµÃÈ¥ÒÀÀµËüµ÷½Ú£¬ÕâÀﻹÓÐÒ»ÖÖ·½·¨
Äã¿ÉÒÔʹÓÃÒ»¸ö²ÎÕÕÈÕÆÚ,ͨ¹ýÏàͬÐÇÆÚÊý³ÉµÄ±¶ÊýµÄÔÀí½øÐвéѯ
select * from test_1
where D
Ïà¹ØÎĵµ£º
SQLÊý¾Ý¿âÖÐÓÃimageÀ´´æ´¢Îļþ,µ«SQLûÓÐÌṩֱ½ÓµÄ´æÈ¡ÎļþµÄÃüÁî.
/*--bcp ʵÏÖ¶þ½øÖÆÎļþµÄµ¼Èëµ¼³ö
Ö§³Öimage,text,ntext×ֶεĵ¼Èë/µ¼³ö
imageÊʺÏÓÚ¶þ½øÖÆÎļþ,°üÀ¨:WordÎĵµ,ExcelÎĵµ,ͼƬ,ÒôÀÖµÈ
text,ntextÊʺÏÓÚÎı¾Êý¾ÝÎļþ
×¢Òâ:µ¼Èëʱ,½«¸²¸ÇÂú×ãÌõ¼þµÄËùÓÐÐÐ
µ¼³öʱ,½ ......
Çë½Ì´ó¼ÒÒ»¸öÓйØSQL½»×¤±¨±í²éѯÎÊÌ⣬»¶Ó¸÷λָ½Ì£¡
ÎÒÏë°Ñͼ1µÄʹÓÃÐÅÏ¢£¬Ê¹ÓÃSQLÓï¾ä£¬ÊµÏÖÈçͼ2µÄ½á¹û¡£
±íÃû
ÐòºÅ
×Ö¶ÎÃû
a
1
c
a
2
d
a
3
e
a
4
f
a
5
g
b
1
h
b
2
i
b
3
j
b
4
k
b
5
l
c
1
m
c
2
n
c
3
o
c
4
p
c
5
q
ͼ1
±íÃû
ÐòºÅ
1
2
3
4
5
......
4£®Êý¾ÝÀàÐÍת»»º¯Êý
¡ñÒþʽת»»
¸³ÖµÊ±¿É½øÐеÄÒþʽת»»ÓÐ
VARCHAR2»òCHAR —¡µNUMBER
VARCHAR2»òCHAR —¡µDATE
NUMBER —¡µVARCHAR ......
1¡¢ËµÃ÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb) (Access¿ÉÓÃ)
·¨Ò»£ºselect * into b from a where 1 <>1
·¨¶þ£ºselect top 0 * into b from a
2¡¢ËµÃ÷£º¿½±´±í(¿½±´Êý¾Ý,Ô´±íÃû£ºa Ä¿±ê±íÃû£ºb) (Access¿ÉÓÃ)
insert into b(a, b, c) select d,e,f from b;
3¡¢ËµÃ÷£º¿çÊý¾Ý¿âÖ®¼ä±íµÄ¿½±´(¾ßÌåÊý¾ÝʹÓà ......
...
)
Óõ½µÄ¹¦ÄÜÓÐ:
1.Èç¹ûÎÒ¸ü¸ÄÁËѧÉúµÄѧºÅ,ÎÒÏ£ÍûËûµÄ½èÊé¼Ç¼ÈÔÈ»ÓëÕâ¸öѧÉúÏà¹Ø(Ò²¾ÍÊÇͬʱ¸ü¸Ä½èÊé¼Ç¼±íµÄѧºÅ);
2.Èç¹û¸ÃѧÉúÒѾ ......