SQL³£Óú¯Êý¼¯½õ 2
ʮһ¡¢ÒÔÉϺ¯ÊýµÄ²¿·ÖʵÀý
1:replace º¯Êý
µÚÒ»¸ö²ÎÊýÄãµÄ×Ö·û´®£¬µÚ¶þ¸ö²ÎÊýÄãÏëÌæ»»µÄ²¿·Ö£¬µÚÈý¸ö²ÎÊýÄãÒªÌæ»»³Éʲô
select replace('lihan','a','b')
-----------------------------
lihbn
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
=========================================================
2:substringº¯Êý
µÚÒ»¸ö²ÎÊýÄãµÄ×Ö·û´®£¬µÚ¶þ¸öÊÇ¿ªÊ¼Ì滻λÖ㬵ÚÈý¸ö½áÊøÌæ»»Î»ÖÃ
select substring('lihan',0,3);
-----
li
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
=========================================================
3:charindexº¯Êý
µÚÒ»¸ö²ÎÊýÄãÒª²éÕÒµÄchar£¬µÚ¶þ¸ö²ÎÊýÄã±»²éÕÒµÄ×Ö·û´® ·µ»Ø²ÎÊýÒ»ÔÚ²ÎÊý¶þµÄλÖÃ
select charindex('a','lihan')
-----------
4
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
===========================================================
4£ºASCIIº¯Êý
·µ»Ø×Ö·û±í´ïʽÖÐ×î×ó²àµÄ×Ö·ûµÄ ASCII ´úÂëÖµ¡£
select ASCII('lihan')
-----------
108
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
================================================================
5£ºncharº¯Êý
¸ù¾Ý Unicode ±ê×¼µÄ¶¨Ò壬·µ»Ø¾ßÓÐÖ¸¶¨µÄÕûÊý´úÂëµÄ Unicode ×Ö·û¡£
²ÎÊýÊǽéÓÚ 0 Óë 65535 Ö®¼äµÄÕýÕûÊý¡£Èç¹ûÖ¸¶¨Á˳¬³ö´Ë·¶Î§µÄÖµ£¬½«·µ»Ø NULL¡£
select nchar(3213)
----
unicode×Ö·û
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
=========================================================
6£ºsoundex
·µ»ØÒ»¸öÓÉËĸö×Ö·û×é³ÉµÄ´úÂë (SOUNDEX)£¬ÓÃÓÚÆÀ¹ÀÁ½¸ö×Ö·û´®µÄÏàËÆÐÔ¡£
SELECT SOUNDEX ('lihan'), SOUNDEX ('lihon');
----- -----
L546 L542
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
=========================================================
7£ºchar
²ÎÊýΪ½éÓÚ 0 ºÍ 255 Ö®¼äµÄÕûÊý¡£Èç¹û¸ÃÕûÊý±í´ïʽ²»ÔÚ´Ë·¶Î§ÄÚ£¬½«·µ»Ø NULL Öµ¡£
SELECT char(125)
----
}
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
===========================================
Ïà¹ØÎĵµ£º
ͨÅä·û_
"_"ºÅ±íʾÈÎÒâµ¥¸ö×Ö·û,¸Ã·ûºÅÖ»ÄÜÆ¥ÅäÒ»¸ö×Ö·û."_"¿ÉÒÔ·ÅÔÚ²éѯÌõ¼þµÄÈÎÒâλÖÃ,ÇÒÖ»ÄÜ´ú±íÒ»¸ö×Ö·û.Ò»¸öºº×ÖֻʹÓÃÒ»¸ö"_"±íʾ.
Àý×Ó£º
if PATINDEX('%[ß¹-×ö]%','ÐèÒªÅжϵÄ×Ö·û')>0 -- ÅжÏÊÇ·ñÓÐ×Ö·û
print 'Óкº×Ö'
else
print 'ÎÞºº×Ö'
ͨÅä·û%
"%"·ûºÅÊÇ×Ö·ûÆ¥Åä·û,ÄÜÆ¥Åä0¸ö»ò¸ü¶à×Ö·ûµÄÈÎÒⳤ¶ ......
ÔÀí£º¶ÔÐèÒªÈ¥ÖØ¸´¼Ç¼µÄ×ֶΰ´×éÅÅÐò£¬È»ºóÈ¡ÆäÖÐÒ»Ìõ¼Ç¼¡£ÔÚ×ܲéѯÓï¾äÖÐʹÓÃinÓï·¨¹ýÂË
È¥µôÖØ¸´¼Ç¼
select * from company where comid in (select Max(comid) from company group by companyname)
µÃµ½Öظ´¼Ç¼Êý
select * from company where comid not in (select Max(comid) from company group by companyn ......
ÔÚʹÓÃSQL*PlusÉú³É±¨¸æÎļþµÄʱºò£¬ÍùÍù»áÒòΪÆäĬÈϵÄÉèÖõ¼ÖÂÊä³öµÄ½á¹û·Ç³£µÄûÓпɶÁÐÔ£¬ÏÂÃæ½éÉÜÒ»¸öÈÕ³£ÖлᱻÓõ½µÄÒ»¸ö½Å±¾£¬ÆäÖаüº¬Ò»Ð©¸ñʽ»¯
Êä³öµÄsetÃüÁî
£¬ÎªÁË·½±ãÀí½â£¬ÎÒ»áÔÚÿһÌõsetÃüÁîÖ®ºó½ô¸ú×ÅÒ»¸ö¼òµ¥µÄ½âÊÍ£¬ÇëÂýÂýÌå»á¡£
sqlplus -s user_name/user_password << EOF >/dev/n ......
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[pr_xls_to_tb]
@path varchar(200),--EXCEL·¾¶Ãû
@tbName varchar(30),--±íÃû
@stName varchar(30) --excelÖÐÒª¶ÁµÄSHEETÃû
as
declare @sql varchar(500),--×îºóÒªÖ´ÐеÄSQL
@stName_Real varchar(35),--ÕæÕýµÄSHEETÃû
......
SQL×¢Èë¹¥»÷·À·¶¼¼ÇÉ
Ò»°ãµÄSQL×¢Èë¹¥»÷¶¼ÊÇͨ¹ý¹¹½¨Ò»Ìõ¸´ÔÓµÄsqlÓï¾ä£¬
ͨ¹ýÍøÒ³Â©¶´À´Ö´ÐÐsqlÓï¾ä£¬´ïµ½¹¥»÷Êý¾Ý¿âµÄÄ¿µÄ¡£
Èçͨ¹ýÎÄÕÂIDÀ´²éѯijһƪÎÄÕµÄÍøÒ³£¬
ͨ³£²ÉÓõÄsqlÓï¾äΪ£º
sql="select top 1 * from articles where articId="&request("id")
ÄÇô¿ÉÒÔ¼òµ ......