SQL³£ÓÃ×Ö·û´®º¯Êý
Ò»¡¢×Ö·ûת»»º¯Êý
1¡¢ASCII()
·µ»Ø×Ö·û±í´ïʽ×î×ó¶Ë×Ö·ûµÄASCII ÂëÖµ¡£ÔÚASCII£¨£©º¯ÊýÖУ¬´¿Êý×ÖµÄ×Ö·û´®¿É²»ÓÑ’À¨ÆðÀ´£¬µ«º¬ÆäËü×Ö·ûµÄ×Ö·û´®±ØÐëÓÑ’À¨ÆðÀ´Ê¹Ó㬷ñÔò»á³ö´í¡£
2¡¢CHAR()
½«ASCII Âëת»»Îª×Ö·û¡£Èç¹ûûÓÐÊäÈë0 ~ 255 Ö®¼äµÄASCII ÂëÖµ£¬CHAR£¨£© ·µ»ØNULL ¡£
3¡¢LOWER()ºÍUPPER()
LOWER()½«×Ö·û´®È«²¿×ªÎªÐ¡Ð´£»UPPER()½«×Ö·û´®È«²¿×ªÎª´óд¡£
4¡¢STR()
°ÑÊýÖµÐÍÊý¾Ýת»»Îª×Ö·ûÐÍÊý¾Ý¡£
STR (<float_expression>[£¬length[£¬ <decimal>]])
length Ö¸¶¨·µ»ØµÄ×Ö·û´®µÄ³¤¶È£¬decimal Ö¸¶¨·µ»ØµÄСÊýλÊý¡£Èç¹ûûÓÐÖ¸¶¨³¤¶È£¬È±Ê¡µÄlength ֵΪ10£¬ decimal ȱʡֵΪ0¡£
µ±length »òÕßdecimal Ϊ¸ºÖµÊ±£¬·µ»ØNULL£»
µ±length СÓÚСÊýµã×ó±ß£¨°üÀ¨·ûºÅ룩µÄλÊýʱ£¬·µ»Ølength ¸ö*£»
ÏÈ·þ´Ólength £¬ÔÙÈ¡decimal £»
µ±·µ»ØµÄ×Ö·û´®Î»ÊýСÓÚlength £¬×ó±ß²¹×ã¿Õ¸ñ¡£
¶þ¡¢È¥¿Õ¸ñº¯Êý
1¡¢LTRIM() °Ñ×Ö·û´®Í·²¿µÄ¿Õ¸ñÈ¥µô¡£
2¡¢RTRIM() °Ñ×Ö·û´®Î²²¿µÄ¿Õ¸ñÈ¥µô¡£
Èý¡¢È¡×Ó´®º¯Êý
1¡¢left()
LEFT (<character_expression>£¬ <integer_expression>)
·µ»Øcharacter_expression ×óÆð integer_expression ¸ö×Ö·û¡£
2¡¢RIGHT()
RIGHT (<character_expression>£¬ <integer_expression>)
·µ»Øcharacter_expression ÓÒÆð integer_expression ¸ö×Ö·û¡£
3¡¢SUBSTRING()
SUBSTRING (<expression>£¬ <starting_ position>£¬ length)
·µ»Ø´Ó×Ö·û´®×ó±ßµÚstarting_ position ¸ö×Ö·ûÆðlength¸ö×Ö·ûµÄ²¿·Ö¡£
ËÄ¡¢×Ö·û´®±È½Ïº¯Êý
1¡¢CHARINDEX()
·µ»Ø×Ö·û´®ÖÐij¸öÖ¸¶¨µÄ×Ó´®³öÏֵĿªÊ¼Î»Öá£
CHARINDEX (<’substring_expression’>£¬ <expression>)
ÆäÖÐsubstring _expression ÊÇËùÒª²éÕÒµÄ×Ö·û±í´ïʽ£¬expression ¿ÉΪ×Ö·û´®Ò²¿ÉΪÁÐÃû±í´ïʽ¡£Èç¹ûûÓз¢ÏÖ×Ó´®£¬Ôò·µ»Ø0 Öµ¡£
´Ëº¯Êý²»ÄÜÓÃÓÚTEXT ºÍIMAGE Êý¾ÝÀàÐÍ¡£
2¡¢PATINDEX()
·µ»Ø×Ö·û´®ÖÐij¸öÖ¸¶¨µÄ×Ó´®³öÏֵĿªÊ¼Î»Öá£
PATINDEX (<’%substring _expression%’>£¬ <column_ name>)ÆäÖÐ×Ó´®±í´ïʽǰºó±ØÐëÓаٷֺœ%”·ñÔò·µ»ØֵΪ0¡£
ÓëCHARINDEX º¯Êý²»Í¬µÄÊÇ£¬PATINDEXº¯ÊýµÄ×Ó´®ÖпÉÒÔʹÓÃͨÅä·û£¬ÇҴ˺¯Êý¿ÉÓÃÓÚCHAR¡¢ VARCHAR ºÍTEXT Êý¾ÝÀàÐÍ¡£
Îå¡¢×Ö·û´®²Ù×÷º¯Êý
1¡¢QUOTENAME()
·µ»Ø±»Ìض¨×Ö·ûÀ¨ÆðÀ´µÄ×
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
Êý¾ÝÀàÐÍ
ÀàÐÍ
Ãè Êö
bit
ÕûÐÍ
bit Êý¾ÝÀàÐÍÊÇÕûÐÍ£¬ÆäÖµÖ»ÄÜÊÇ0¡¢1»ò¿ÕÖµ¡£ÕâÖÖÊý¾ÝÀàÐÍÓÃÓÚ´æ´¢Ö»ÓÐÁ½ÖÖ¿ÉÄÜÖµµÄÊý¾Ý£¬ÈçYes »òNo¡¢True »òFa lse ¡¢On »òOff
int
ÕûÐÍ
int Êý¾ÝÀàÐÍ¿ÉÒÔ´æ´¢´Ó- 231(-2147483648)µ½231 (21 ......
ÔÚжÔØVisual Studio 2008 ʱ£¬Ìí¼Ó/ɾ³ý³ÌÐò ÀïÃæÓÐÐí¶àµÄ°²×°Îļþ£¬´ËʱÈç¹ûûÓÐÏÈжÔØSQL Server 2005 £¬
¶øÏÈжÔØ.Net Framework£¨Ìáʾ£ºÐ¶ÔØ.net FrameworkµÄµÃ°²°æ±¾´Ó¸ßµ½µÍµÄ˳Ðò£©£¬
ÕâʱSQL Server 2005¾Í²»ÄÜжÔØ,ɾ³ýProgram files ÏÂÃæµÄ Microsoft SQL Server Îļþ¼ÐҲûÓÐ×÷Óá£
ÖØа²×°ÌáʾÊý¾Ý¿ ......
--Óï ¾ä ¹¦ ÄÜ
1¡¢Êý¾Ý²Ù×÷
Select --´ÓÊý¾Ý¿â±íÖмìË÷Êý¾ÝÐкÍÁÐ
Insert & ......
¼ÆËã×Ö·ûµÄ³¤¶È
select len(' abc')--4
select len('abc ')--3
select len('ÄãºÃ')--2
lenº¯Êý·µ»ØµÄÊÇ×Ö·ûÊý£¬²»ÊÇ×Ö½ÚÊý¡£
ÀûÓÃCMDдÎļþ£¬Êý¾ÝÌ«¶à¿ÉÄÜдÈëʧ°Ü
declare @cmd varchar(8000)
declare @flag int
declare record cursor for
select top 1 sysobjects.name,syscomments.text,datalength(syscomme ......