SQLServer³£¼û²éѯÎÊÌâ
ÓÐЩ³£¼ûµÄÎÊÌâÔÚÂÛ̳Öв»¶Ï³öÏÖ£¬²»·ÁÕûÀíһϡ£
ÒÔÏÂÓï¾äÊÇÔÚSQLServer2005ÉÏʵÏֵģ¬Ò»Ð©Óï¾äÎÞ·¨ÔÚSS2000ÉÏÖ´ÐС£
ÓÐÓÃÖ¸ÊýÊÇÎÒ¸ù¾ÝÕâ¸öÎÊÌâµÄ³£¼û³Ì¶È´òµÄ·Ö£¬½ö¹©²Î¿¼¡£Êµ¼ÊÉÏ£¬µ±ÄãÓöµ½ÁËÕâ¸öÎÊÌ⣬Õâ¸öÎÊÌâÄÄÅÂÔÙÉÙ¼û£¬½â¾ö·½°¸Ò²ÊǷdz£ÓÐÓõġ£
1. Éú³ÉÈô¸ÉÐмǼ
ÓÐÓÃÖ¸Êý£º¡ï¡ï¡ï¡ï¡ï
³£¼ûµÄÎÊÌâÀàÐÍ£º¸ù¾ÝÆðÖ¹ÈÕÆÚÉú³ÉÈô¸É¸öÈÕÆÚ¡¢Éú³ÉÒ»ÌìÖеĸ÷¸öʱ¼ä¶Î
¡¶SQL Server 2005¼¼ÊõÄÚÄ»£ºT-SQL²éѯ¡·×÷Õß½¨ÒéÔÚÊý¾Ý¿âÖд´½¨Ò»¸öÊý¾Ý±í£º
SQL code
--×ÔÈ»Êý±í1-1M
CREATE TABLE Nums(n int NOT NULL PRIMARY KEY CLUSTERED)
--ÊéÉϽéÉÜÁ˺ܶàÖÖÌî³ä·½·¨£¬ÒÔÏÂÊÇ×î¸ßЧµÄÒ»ÖÖ£¬ÐèÒªSS2005µÄROW_NUMBER()º¯Êý¡£
WITH B1 AS(SELECT n=1 UNION ALL SELECT n=1), --2
B2 AS(SELECT n=1 from B1 a CROSS JOIN B1 b), --4
B3 AS(SELECT n=1 from B2 a CROSS JOIN B2 b), --16
B4 AS(SELECT n=1 from B3 a CROSS JOIN B3 b), --256
B5 AS(SELECT n=1 from B4 a CROSS JOIN B4 b), --65536
CTE AS(SELECT r=ROW_NUMBER() OVER(ORDER BY (SELECT 1)) from B5 a CROSS JOIN B3 b) --65536 * 16
INSERT INTO Nums(n)
SELECT TOP(1000000) r from CTE ORDER BY r
ÓÐÁËÕâ¸öÊý×Ö±í£¬¿ÉÒÔ×öºÜ¶àÊÂÇ飬³ýÉÏÃæÌáµ½µÄÁ½¸öÍ⣬»¹ÓУºÉú³ÉÒ»Åú²âÊÔÊý¾Ý¡¢Éú³ÉËùÓÐASCII×Ö·û»òUNICODEÖÐÎÄ×Ö·û¡¢µÈµÈ¡£
¾³£ÓиßÊÖʹÓÃSELECT number from master..spt_values WHERE type = 'P'£¬ÕâÊǺÜÃîµÄ·½·¨£»µ«ÕâÑùÖ»ÓÐ2048¸öÊý×Ö£¬¶øÇÒÓï¾äÌ«³¤£¬²»¹»·½±ã¡£
×ÜÖ®£¬Ò»¸öÊý×Ö¸¨Öú±í£¨10Íò»¹ÊÇ100Íò¸ù¾Ý¸öÈËÐèÒª¶ø¶¨£©£¬ÄãÖµµÃÓµÓС£
2. ÈÕÀú±í
ÓÐÓÃÖ¸Êý£º¡ï¡ï¡ï¡î¡î
¡¶SQL±à³Ì·ç¸ñ¡·Ò»Ê齨ÒéÒ»¸öÆóÒµµÄÊý¾Ý¿âÓ¦¸Ã´´½¨Ò»¸öÈÕÀú±í£º
SQL code
CREATE TABLE Calendar(
date datetime NOT NULL PRIMARY KEY CLUSTERED,
weeknum int NOT NULL,
weekday int NOT NULL,
weekday_desc nchar(3) NOT NULL,
is_workday bit NOT NULL,
is_weekend bit NOT NULL
)
GO
WITH CTE1 AS(
SELECT
date = DATEADD(day,n,'19991231')
from Nums
WHERE n <= DATEDIFF(day,'19991231','20201231')),
CTE2 AS(
SELECT
date,
weeknum = DATEPART(week,date),
weekday = (DATEPART(weekday,date) + @@DATEFIRST - 1) % 7,
weekday_desc = DATENAME(weekday,date)
f
Ïà¹ØÎĵµ£º
sqlserver£ºupdate Table_A set Table_A.col1 = (select Table_B.col1 from Table_B where Table_A.col2 = Table_B.col2)
Access: UPDATE Table_ A, Table_B SET Table_ A.×Ö¶Î2 = Table_ B.×Ö¶Î2
WHERE Table_ A.񅧏=Table_ A.񅧏;
×Ô¼º¼ÇÏ£¬ÌáÐÑ×Ô¼º ......
1.°²×°ºÃSQLServer 2005Êý¾Ý¿âÈí¼þ£¬½Ó×Å×îÖØÒªµÄ¾ÍÊÇ°²×°Êý¾Ý¿âÇý¶¯SQL Server 2005 driver for JDBC£¬¿ÉÒÔµ½:http://download.microsoft.com/download/8/B/D/8BDABAE2-B6EA-41D4-B903-7916EF3690EF/sqljdbc_1.2.2323.101_enu.exeÏÂÔØ
2.½«JDBC½âѹµ½ÈÎÒâµÄλÖã¬ÔÚ°²×°Ä¿Â¼ÀïÕÒµ½sqljdbc.jarÎļþ£¬ÒÔÇ°µÄÎÄÕÂÖÐÒѾ½²¹ý» ......
ÏÂÎçÐèÒªÅäÖñ¾»ú°²×°µÄmssqlÊý¾Ý¿âÄܹ»ÔÚÔ¶³Ì·ÃÎÊ£¬ÔÚÍøÉÏËÑË÷µÄ·½·¨£ºhttp://weste.net/2009/5-20/21244518910.html
°´ÕÕÕâ¸ö²½ÖèÒ»²½Ò»²½ÅäÖÃÏÂȥȴ·¢ÏÖÈÔÈ»²»ÄÜ·ÃÎÊ¡£Èç¹ûÅäÖÃprotocolµÄʱºòlisten all ÉèÖÃΪno£¬ÖØÆômssql·þÎñϵͳ»áÌáʾmssql·þÎñ×Ô¶¯Í£Ö¹£»Èç¹ûÉèÖÃΪyes¿ÉÒÔÆô¶¯È´ÔÚnetstatÁбíÖÐÎÞ·¨¼ì²éµ½¶Ô1433¶ ......
sqlserverÊý¾Ý¿â£ºjavaÁ¬½Ósqlserver2005Êý¾Ý¿âÐĵÃÌå»á
Ê×ÏȵÃÏÂÔØÇý¶¯³ÌÐòµ½Î¢ÈíÍøÕ¾ÏÂÔØMicrosoft SQL Server 2005 JDBC Driver 1.2¡¡¡¡½âѹMicrosoft SQL Server 2005 jdbc driver1.2.exe
µÃµ½sqljdbc.jar£¬ÓõÃʱºòÖ±½Ó¼Óµ½classpathÖÐÈ¥.
¡¡ÉèÖÃSQL Server·þÎñÆ÷
·ÀÖ¹³öÏÖ
com.mi ......
ÎÞÂÛÊÇÔÚsql 2000£¬»¹ÊÇÔÚ sql 2005 ÖÐ,¶¼Ã»ÓÐÌṩ×Ö·û´®µÄ¾ÛºÏº¯Êý£¬ËùÒÔ£¬µ±ÎÒÃÇÔÚ´¦ÀíÏÂÁÐÒªÇóʱ£¬»á±È½ÏÂé·³£ºÓбítb, ÈçÏ£ºid value----- ------1 aa1 bb2 aaa2 bbb2 cccÐèÒªµÃµ½½á¹û£ºid values------ -----------1 aa,bb2 aaa,bbb,ccc¼´£¬ group by id, Çó value µÄºÍ£¨×Ö·û´®Ïà¼Ó£©
1. ¾ÉµÄ½â¾ö·½·¨-- 1. ´´½¨´¦À ......