Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLServerÖÐÎÄ´¦Àí

Ê×ÏȲå¾äÌâÍâ»°£º´´½¨Ò»¸ö×ÔÈ»Êý±íNums¡£ÕâÊÇ¡¶SQL Server 2005¼¼ÊõÄÚÄ»£ºT-SQL²éѯ¡·Ò»ÊéµÄ½¨Òé¡£
ÔÚSQL Server 2005ÖУ¬¿ÉÒÔ½èÓÃROW_NUMBERÅÅÃûº¯ÊýÇáËÉÉú³ÉÎÒÃÇËùÐèµÄ×ÔÈ»Êý±í£º
--×ÔÈ»Êý±í1-1M
CREATE TABLE Nums(n int NOT NULL PRIMARY KEY CLUSTERED)
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
ÒÔÉÏÓï¾äÉú³ÉÇ°100Íò¸ö×ÔÈ»Êý¡£
ÒÔÏ¿ªÊ¼ÕýÌâ¡£
Ò»¡¢×Ö·û±àÂëÓëÅÅÐò¹æÔò
×ö¹ýWeb¿ª·¢µÄÈ˶Ô×Ö·û±àÂëÒ»¶¨²»Ä°Éú¡£¼òµ¥À´Ëµ£¬ÈËËùÄܹ»Ê¶±ðµÄ×Ö·ûÈç“A”¡¢“Ò»”Óë¼ÆËã»úÄÚ²¿²Ù×÷µÄÊý×Ö01000001¡¢1101001010111011ÊDz»Ò»ÑùµÄ£¬ÐèÒª½¨Á¢Ò»ÖÖ¶ÔÓ¦¹ØϵÀ´ÈüÆËã»úÄܹ»“ʶ±ð”ÈËÃÇËùʹÓõÄ×Ö·û£¨»òÕß˵ÊÇÈÃÈËÃÇÄܹ»ÓÃ×Ô¼ºÏ°¹ßµÄ·½Ê½Ê¶±ð¼ÆËã»ú²Ù×÷µÄÊý×Ö£©£¬×Ö·û±àÂë¾ÍÊÇÕâ¸ö¶ÔÓ¦¹Øϵ¡£
¶ÔÓÚÓ¢ÓïÀ´Ëµ£¬´óСд×Öĸ¼ÓÊý×Ö¼Ó±êµã·ûºÅ£¬×ܹ²Ò²²»»á³¬¹ý128¸ö£¬Ò»¸ö×ֽھ͹»ÓÃÁË£»ASCII±àÂëֻʹÓÃÁËÒ»¸ö×Ö½ÚÖеÄ7룬±ãÒѾ­°üÀ¨ÁËÓ¢Óï³£ÓÃ×Ö·û£¬»¹¼ÓÉÏÁËÒ»×éµç´«´ò×Ö»úʱ´úµÄ¿ØÖÆ×Ö·û£¨ÖÁ½ñÈÔÔÚʹÓÃÆäÖм¸¸ö£©¡£
È»¶øÊÀÉϲ¢²»½öÓÐÓ¢ÓŷÖÞһЩÓïÑÔÐèҪʹÓõÄһЩÖØÒô×Ö·û²¢Ã»ÓаüÀ¨ÔÚASCII±àÂëÖУ»¶øÑÇÖÞµÄCJK£¨Ö¸China+Japan+Korea£©ÓïÑÔ×Ö·û¶à´ï¼¸Íò¸ö£¬¸üÊÇÔ¶Ô¶³¬¹ýÁËÒ»¸ö×Ö½ÚËùÄܱíʾµÄ·¶Î§£»ÔÙ¼ÓÉÏ°¢À­²®Óϣ²®À´ÓïµÈµÈ……
½â¾ö°ì·¨×ÔÈ»ÊÇÀ©³ä×Ö·û±àÂëλÊý¡£Ë«×Ö½Ú¿ÉÒÔ±íʾ65536¸ö×Ö·û£¬Í¨³£Çé¿öÏÂÊÇ×ã¹»ÁË¡£µ«ÕâʱÓÖÓÐÒ»¸öеÄÎÊÌ⣺µ±¼ÆËã»ú¶Áµ½Á½¸öÁ¬ÐøµÄ×Ö½Ú£¬ËüÓ¦¸Ã½«Ö®Àí½âΪÁ½¸öµ¥¶ÀµÄ×Ö·û»¹ÊÇÒ»¸ö×Ö·û£¿±àÂë·½°¸ÐèÒª½â¾öÕâ¸öÎÊÌâ¡£
µÚÒ»ÖÖ·½°¸ÊÇ΢ÈíÒýÈëµÄ´úÂëÒ³µÄ¸ÅÄî¡£ASCIIֻʹÓÃÁËÒ»¸ö×Ö½ÚµÄ7룬×Ö½Ú×î¸ßλÊÇ0£¬ÄÇô¿ÉÒÔÓÃ×î¸ßλÊÇ1µÄ·¶Î§À´±íʾÀ©Õ¹×Ö·û¡£¶ÔÓÚ¶àÊýÅ·ÖÞÓïÑÔ£¬Ò»¸ö×Ö½ÚµÄ256¸ö×Ö·ûÒÑÈ»×ã¹»£¬ÄÇô±ãÓÃ×Ö½Ú×î¸ßλÊÇ1µÄ128¸ö×Ö·ûÀ´±íʾÈçÖØÒô×Ö·û¡¢ÖƱí·ûµÈÀ©Õ¹×Ö·û£»¶ÔÓÚÑÇÖÞÓïÑÔ£¬Ê¹ÓÃÁ½¸öÁ¬ÐøµÄ×î¸ßλÊÇ1µÄ×Ö½ÚÀ´±íʾCJK×Ö·û£¬ÕâÑù£¬µ±¼ÆËã»ú¶Áµ½Ò»¸ö×î¸ßλÊÇ0µ


Ïà¹ØÎĵµ£º

SQLSERVER´óÅúÁ¿Êý¾Ý²Ù×÷ʱËùÕ¼ÓÃÄÚ´æÊÍ...

ÏÖÏó£º
ÏÖÔÚ×öÒ»¸ö³ÌÐò£¬¶ÔÊý¾Ý¿âµÄ¼¸¸ö×°ÓдóÁ¿Êý¾ÝµÄ±í½øÐвÙ×÷£¬¶ÔÆäÖеÄÒ»¸ö±í½øÐÐ
Ñ­»·²Ù×÷£¬ÒÔ´¦ÀíÆäËûµÄ¼¸¸ö±í¡£ÆäÖÐÓõ½Á˼¸¸öquery,update£¬µ±³ÌÐòÅܵĹý³ÌÖУ¬
SQLSERVERµÄÄÚ´æ²»¶ÏµÄÔö³¤£¬ÅÜÍêºó¹Ø±Õ³ÌÐòÍ˳öºóÒ²²»½µÏÂÀ´¡£
½â¾ö£º
ÕâÊÇSQLµÄÄÚ´æ¹ÜÀí»úÖƾö¶¨µÄ£¬SQL¹ÜÀíÄÚ´æµÄÔ­ÔòÊÇÕâÑùµÄ,Ö»ÒªÄãµÄÄÚ´æ¹» ......

SQLServer ÖбíµÄ×ÔÔö³¤ÁÐ

1.½¨±í(Create table)ʱʹÓàIDENTITY (SEED,INCREMENT)
ÆäÖÐSEEDÊÇÆðʼֵ£¬INCREMENTÊÇÔöÁ¿¡£
Àý£º
CREATE TABLE mytable1
    (
      [user_id] BIGINT NOT NULL
                       IDENTITY(1, 1) , ......

sqlserver 2005 split function

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
create function [dbo].[split](@str nvarchar(1000),@word varchar(5),@no
int) returns nvarchar(500)
as begin
    declare @len int
    declare @index int
    set @index=charindex(@word,@str)
   ......

ʹÓÃT SQL»ñÈ¡µ½SQLServer IpºÍ¶Ë¿ÚºÅ

ÔÚƽʱµÄ¹¤×÷¹ý³ÌÖУ¬×÷ΪDBA½ÇÉ«¹ÜÀíÊý¾Ý¿â£¬Í·ÄÔÖеÄÓ¡ÏóÍùÍùÊÇÊý¾Ý¿âʵÀýÃû³Æ£¬¶ø²»»áÈ¥¹ØÐÄServerµÄIP£¬¶ø×÷ΪDeveloperµÄ½ÇÉ«£¬ËûÃÇÍùÍùÏëÖªµÀÖªµÀServer IpºÍ¶Ë¿ÚºÅ¡£ËùÒÔ£¬DBA»á¾­³£±»Îʼ°µ½£ºXXXʵÀýµÄIPºÍ¶Ë¿ÚºÅÊÇʲô£¿
Õâ¸öÎÊÌ⣬µ±È»ÎÒÃÇ¿ÉÒÔLoginµ½OS²é¿´IP¡¢Ê¹ÓÃÅäÖƹÜÀí¹¤¾ß»ñÈ¡µ½¶Ë¿ÚºÅ¡£µ«ÊÇ£¬Õâ¸ö·½·¨·Ç ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ