ʵÏÖsqlserver·ÖÒ³²éѯÓï¾ä
sqlServer£º
Ò»´Î²éѯ£¬Êý¾Ý¿âÖ»·µ»ØÒ»Ò³µÄÊý¾Ý¡£¶ø²»ÊÇÈ¡³öËùÓеÄÊý¾Ý¡£
pagesize£º ÿҳÏÔʾ¼Ç¼Êý
cureentpage£ºµ±Ç°Ò³Êý
select * from ( select TOP pagesize * from ( SELECT TOP pagesize*cureentpage * from my_table ORDER BY id ASC ) as amyTable ORDER BY id DESC ) as bmyTable ORDER BY id ASC
¼ÙÉè¹²ÓÐÓÐ8Ìõ¼Ç¼£¬Ã¿Ò³ÏÔʾ3Ìõ¼Ç¼£¬id Ϊ3£¬6£¬7£¬37
µÚÒ»Ò³£¨Ê×Ò³£©
select * from ( select TOP 3 * from ( SELECT TOP 3*1 * from my_table ORDER BY id ASC ) as amyTable ORDER BY id DESC ) as bmyTable ORDER BY id ASC
µÚ¶þÒ³
select * from ( select TOP 3 * from ( SELECT TOP 3*2 * from my_table ORDER BY id ASC ) as amyTable ORDER BY id DESC ) as bmyTable ORDER BY id ASC
µÚÈýÒ³£¨Î²Ò³£©
select * from ( select TOP 8-2*3 * from ( SELECT TOP 8-3*2 * from my_table ORDER BY id ASC ) as amyTable ORDER BY id DESC ) as bmyTable ORDER BY id ASC
Ïà¹ØÎĵµ£º
ת»»·½·¨£º convert(nvarchar(8),starttime,14)
100 (1, 2)
ĬÈÏÉèÖÃ
mon dd yyyy hh:miAM£¨»ò PM£©
101
&nbs ......
½ñÌìÔÚдÊÓͼʱ£¬Óöµ½Òª°ÑDatetimeÀàÐÍתVarcharÀàÐÍ¡£ÒÔǰÔÚORALCE¾ÍÈÝÒ×£¬Ö±½ÓToChar(getdate(),'yyyy-mm-dd')¡£ÔÚSQL Server 2005
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
200 ......
create database DB
use DB
--רҵ±í
create table major
(spno char(5) not null primary key,
spname varchar(20) not null,
pno char(2) )
--ѧÉú±í
create table student
(sno char(7) not null primary key,
sname varchar(20) not null,
ssex char(2) not null,
sag ......
jdbcÅäÖÃÓï¾äΪ: jdbc:microsoft:sqlserver://server_name:1433
ÈçÔËÐгÌÐòʱ³öÏÖ "Error establishing socket" ´íÎó,ÔòÓ¦½øÐÐÈçϵ÷ÊÔ:
1 ¼ì²éSQL SERVER ÊÇ·ñÔÊÐíÔ¶³Ì·ÃÎÊ.¾ßÌå²½Öè:
1)´ò¿ª"ÆóÒµ¹ÜÀíÆ÷",´ò¿ª¿ØÖÆÌ¨¸ùĿ¼>SQL Server ×é>Êý¾Ý¿â
2)ÔÚÏàÓ¦"Êý¾Ý¿â"Éϵ¥»÷ÓÒ¼ü,Ñ¡Ôñ"ÊôÐÔ"
3)Ñ¡Ôñ"Á¬½Ó"Ñ ......
DATEDIFF(datepart, startdate, enddate)
Datepart Abbreviations
year yy, yyyy
quarter qq, q
month mm, m
......