SQLº¯Êý´óÈ«2
--
¾ÛºÏº¯Êý
use
pubs
go
select
avg
(
distinct
price)
--
Ëãƽ¾ùÊý
from
titles
where
type
=
'
business
'
go
use
pubs
go
select
max
(ytd_sales)
--
×î´óÊý
from
titles
go
use
pubs
go
select
min
(ytd_sales)
--
×îСÊý
from
titles
go
use
pubs
go
select
type,
sum
(price),
sum
(advance)
--
ÇóºÍ
from
titles
group
by
type
order
by
type
go
use
pubs
go
select
count
(
distinct
city)
--
Çó¸öÊý
from
authors
go
use
pubs
go
select
stdev
(royalty)
--
·µ»Ø¸ø¶¨±í´ïʽÖÐËùÓÐÖµµÄͳ¼Æ±ê׼ƫ²î
from
titles
go
use
pubs
go
select
stdevp
(royalty)
--
·µ»Ø±í´ïʽÖÐËùÓÐÖƵÄÌî³äͳ¼Æ±ê׼ƫ²î
from
titles
go
use
pubs
go
select
var
(royalty)
--
·µ»ØËùÓÐÖµµÄͳ¼Æ·½²î
from
titles
go
use
pubs
go
select
varp
(royalty)
--
·µ»ØËùÓÐÖµµÄÌî³äµÄͳ¼Æ·½²î
from
titles
go
--
Êýѧº¯Êý
select
sin
(
23.45
),
atan
(
1.234
),
rand
(),
PI
(),
sign
(
-
2.34
)
--
ÆäÖÐrandÊÇ»ñµÃÒ»¸öËæ»úÊý
--
ÅäÖú¯Êý
SELECT
@@VERSION
--
»ñÈ¡µ±Ç°Êý¾Ý¿â°æ±¾
SELECT
@@LANGUAGE
--
µ±Ç°ÓïÑÔ
--
ʱ¼äº¯Êý
select
getdate
()
as
'
wawa_getdate
'
--
µ±Ç°Ê±¼ä
select
getutcdate()
as
'
wawa_getutcdate
'
--
»ñÈ¡utcʱ¼ä
select
day
(
getdate
())
as
'
wawa_day
'
--
È¡³öÌì
select
month
(
getdate
())
as
'
wawa_month
'
--
È¡³öÔÂ
select
year
(
getdate
())
as
'
wawa_year
'
--
È¡³öÄê
select
dateadd
(d,
3
,
getdate
())
as
wawa_dateadd
--
¼ÓÈýÌì,×¢Òâ'd'±íʾÌì,'m'±íʾÔÂ,'yy'±íʾÄê,ÏÂÃæÒ»Ñù
select
datediff
(d,
'
2004-07-01
'
,
'
2004-07-15
'
)
as
wawa_datediff
--
¼ÆËãÁ½¸öʱ
¼äµÄ²î
select
datename
(d,
'
2004-07-15
'
)
as
wawa_datename
--
È¡³öʱ¼äµÄijһ²¿·Ö
select
datepart
(d,
getdate
())
as
wawa_datepart &
Ïà¹ØÎĵµ£º
SQL ServerÊý¾Ý¿â±¸·ÝÓÐÁ½ÖÖ·½Ê½£¬Ò»ÖÖÊÇʹÓÃBACKUP DATABASE½«Êý¾Ý¿âÎļþ±¸·Ý³öÈ¥£¬ÁíÍâÒ»ÖÖ¾ÍÊÇÖ±½Ó¿½±´Êý¾Ý¿âÎļþmdfºÍÈÕÖ¾ÎļþldfµÄ·½Ê½¡£ÏÂÃ潫Ö÷ÒªÌÖÂÛһϺóÕߵı¸·ÝÓë»Ö¸´¡£±¾Îļٶ¨ÄúÄÜÊìÁ·Ê¹ÓÃSQL Server Enterprise Manager(SQL ServerÆóÒµ¹ÜÀíÆ÷)ºÍSQL Server Quwey Analyser(SQL Server²éѯ·ÖÎöÆ÷)
¡¡¡¡
¡ ......
ÎÒÃÇÔÚ¿ª·¢¹ý³ÌÖУ¬¾³£Óöµ½ÕâÑùÎÊÌ⣬¾ÍÊÇÒªÇó¶¨ÆÚ½øÐÐÊý¾Ý¿âµÄ¼ì²é£¬Èç¹û·¢ÏÖÌض¨Êý¾Ý£¬ÄÇô¾ÍÒª½øÐÐijÏî²Ù×÷£¬Õâ¸öÐèÇóÄØ£¬¿ÉÒÔÀûÓÃWindowsµÄ¼Æ»®ÈÎÎñ£¬¶¨ÆÚÖ´ÐÐijһ¸öÓ¦ÓóÌÐò£¬È¥¼ìË÷Êý¾Ý£»Ò²¿ÉÒÔÈóÌÐò×Ô¼º¿ØÖÆ¡£ÆäʵSQL Server×Ô¼ºÒ²¿ÉÒÔ´´½¨¼Æ»®ÈÎÎñ£¬¶¨ÆÚ½øÐÐÖ´ÐС£Èç¹ûÊý¾Ý¿â·þÎñÆ÷ÔÊÐí£¬¿ÉÒÔ¿¼ÂDzÉÓÃÕâÖÖ·½Ê½¡£
......
¾³£»áÓÐʱºòÒªÓõ½²éѯµ±Ì죬½ü¼¸Ì죬±¾ÖÜ£¬±¾ÔµÄÏà¹ØÊý¾Ý£¬ËùÒԼǼһÏÂÕâЩ±È½ÏÌØÊâµÄSQLÓï¾ä~~
--µ±Ìì
(usrRegTime >=CONVERT(varchar(10),getDate(),120)+' 00:00:00' and usrRegTime <=CONVERT(varchar (10),getDate(),120)+' 23:59:59')
--½üÈýÌì
DateDiff(day,usrRegTime,getdate()) <=3
--±¾ÖÜ
......
½ñÌì°²×°SQL SERVER 2000 ¸öÈ˰棬°²×°×îºóµ¯³ö´íÎó¶Ô»°¿ò£º
“°²×°³ÌÐòÅäÖ÷þÎñÆ÷ʧ°Ü¡£²Î¿¼·þÎñÆ÷´íÎóÈÕÖ¾ºÍC:\windows\sqlstp.log”£¬´Ó¶øÎÞ·¨°²×°¡£
µ½¾ßÌåµÄĿ¼²é¿´ÏÔʾ"Ò»°ãÐÔÍøÂç´íÎó"£¬ÔÚÍøÉÏËÑË÷ÎÊÌâÔÒò¼°½â¾ö·½°¸ÈçÏ£º
´ËÎÊÌâÊôÓÚsql serverµÄbug, GetComputerName ÓÃÓÚ»ñÈ¡±¾µØ¼ÆËã»úÃû¡£ ......
ÎÒÃÇÔÚƽ³£µÄϵͳ¿ª·¢Öг£³£»áÓöµ½ÏñÎÞÏÞ¼¶·ÖÀàÕâÑùµÄÊ÷ÐͽṹÊý¾Ý£¬ÏÖÌṩһ¸ö¿ÉÓõÄÊý¾Ý¿â´æ´¢¹ý³Ì£¬¿ÉÒÔÍê³ÉÊ÷ÐͽṹÊý¾ÝµÄÅÅÐò¡£
»·¾³£ºwindows7+Sql Server 2008
˵Ã÷£ºÏÂÃæ´úÂëÒѾת»»³ÉSql server2000µÄ½Å±¾£¬´¦ÀíЧ¹ûÈçÏ£¬¿´sortname×ֶνá¹û,´úÂë¾¹ý²âÊÔ¡£
´´½¨Ê÷Ðͱí
CREATE TABLE [dbo].[categories](
......