sqlÓï¾ä ·ÃÎʲ»Í¬Êý¾Ý¿â·þÎñÆ÷ÖеÄÊý¾Ý¿â¶ÔÏóµÄ·½·¨
ÔÚÎÒÃÇ×öÊý¾Ý¿â³ÌÐò¿ª·¢µÄʱºò£¬¾³£»áÓöµ½ÕâÖÖÇé¿ö£ºÐèÒª½«Ò»¸öÊý¾Ý¿â·þÎñÆ÷ÖеÄÊý¾Ýµ¼Èëµ½ÁíÒ»¸öÊý¾Ý¿â·þÎñÆ÷µÄ±íÖС£Í¨³£ÎÒÃÇ»áʹÓÃÕâÖÖ·½·¨£ºÏÈ°ÑÒ»¸öÊý¾Ý¿âÖеÄÊý¾ÝÈ¡³öÀ´·Åµ½Ä³³ö£¬È»ºóÔÙ°ÑÕâЩÊý¾ÝÒ»ÌõÌõ²åÈ뵽ĿµÄÊý¾Ý¿âÖУ¬ÕâÖÖ·½·¨Ð§Âʽϵͣ¬Ð´Æð³ÌÐòÀ´Ò²ºÜ·±Ëö£¬ÈÝÒ׳ö´í¡£ÁíÍâÒ»ÖÖ·½·¨ÊÇʹÓÃbcp»òBULK INSERTÓï¾ä£¬½«Êý¾Ýµ¼Èëµ½Ò»¸öÎļþÖУ¬ÔÙ´Ó´ËÎļþÖе¼³öµ½Ä¿µÄÊý¾Ý¿â£¬ÕâÖÖ·½·¨ËäȻЧÂÊÉԸߣ¬µ«Ò²Óкܶ಻ÈçÒâµÄµØ·½£¬µ¥ÊÇÔÚµ¼ÈëʱÔõÑùÕÒµ½ÁíÍâһ̨»úÆ÷ÉϵÄÊý¾Ýµ¼ÈëÎļþ¾ÍºÜÂé·³¡£
×î·½±ãµÄÒ»ÖÖ·½·¨£¬ÎÒÏëÒ²ÊÇЧÂÊ×î¸ßµÄ·½·¨£¬Ó¦¸ÃÊÇÕâÑù£º
±ÈÈçÓÐÁ½¸öÊý¾Ý¿â·þÎñÆ÷£ºlnºÍgx£¬ÀïÃ涼ÓÐÒ»¸öÊý¾Ý¿âtaxitemp£¨Ò²¿ÉÒÔ²»Í¬Ãû£©£¬Êý¾Ý¿âÀïÓÐÒ»¸ö±í£¬½Ðusers£¬ÎÒÃÇÏÖÔÚÏë°ÑlnÖеÄusersÊý¾Ýµ¼Èëµ½gxÖУ¬¿ÉÒÔÕâÑùдsqlÓï¾ä£¨¼ÙÉèÏÖÔÚÁ¬½ÓµÄÊÇzlÊý¾Ý¿â£©£º
insert into gx.taxitemp.dbo.users
select * from users
ÕâÑù£¬Í¨¹ýÒ»ÌõsqlÓï¾ä¾ÍÍê³ÉÁ˲»Í¬Êý¾Ý¿â·þÎñÆ÷Ö®¼äµÄÊý¾Ý¸´ÖÆ¡£
ÓÐÈË»á˵£¬ÕâÖÖsqlÓï¾äÎÒÒ²»áд£¬ÎÒÒ²Ïëµ½ÁË£¬µ«ÊÇû°ì·¨Ö´ÐС£
µÄÈ·£¬µ¥´¿µÄÕâÑùÒ»ÌõÓï¾äû°ì·¨Ö´ÐУ¬ÒòΪÊý¾Ý¿â²»ÖªµÀgxÊÇʲô·þÎñÆ÷£¬Ò²²»ÖªµÀÔõÑùµÇ¼£¬µ±È»»á±¨´í¡£
ÎÒÃÇ¿ÉÒÔÕâÑù½â¾ö×¢²áÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷ºÍµÇ¼µÄÎÊÌ⣺
×¢²áÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷£º
EXEC sp_addlinkedserver 'gx', N'SQL Server'
×¢²áÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷µÄµÇ¼·½·¨£º
EXEC sp_addlinkedsrvlogin 'gx', 'false', NULL, 'sa', 'zz'
Ö»ÒªÎÒÃÇÏÈÖ´ÐÐÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷×¢²áºÍµÇ¼·½·¨×¢²á£¬È»ºó¾Í¿ÉÒÔ°ÑÔ¶³ÌÊý¾Ý¿âµ±³É±¾µØÊý¾Ý¿âʹÓÃÁË
Ïà¹ØÎĵµ£º
¡¡1¡¢varchar(max)¡¢nvarchar(max)ºÍvarbinary(max)Êý¾ÝÀàÐÍ×î¶à¿ÉÒÔ±£´æ2GBµÄÊý¾Ý£¬¿ÉÒÔÈ¡´útext¡¢ntext»òimageÊý¾ÝÀàÐÍ¡£
CREATE TABLE myTable
(
id INT,
content VARCHAR(MAX)
)
¡¡¡¡2¡¢XMLÊý¾ÝÀàÐÍ
¡¡¡¡XMLÊý¾ÝÀàÐÍÔÊÐíÓû§ÔÚSQL ServerÊý¾Ý¿âÖб£´æXMLƬ¶Î»òÎĵµ¡£
¡¡¡¡´íÎó´¦Àí Error Handling
¡ ......
1.°´ÐÕÊϱʻÅÅÐò:
Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.·ÖÒ³SQLÓï¾ä
select * from(select (row_number() OVER (ORDER BY tab.ID Desc)) as rownum,tab.* from ±íÃû As tab) As t where rownum between ÆðʼλÖà And ½áÊøλÖÃ
3.»ñÈ¡µ±Ç°Êý¾Ý¿âÖеÄËùÓÐÓû§± ......
ÓÐЩʱºòÎÒÃÇÐèÒª²éѯÊý¾Ý¿âÖеÄʱ¼ä×ֶΣ¬ÀýÈç2009-11-11 11:11:11:111 ÕâÑùµÄʱ¼ä¸ñʽ¡£
¶øÎÒÃÇÓÐЩʱºò²»ÓðÑÕû¸öµÄ×ֶβéѯ³öÀ´£¬ÐèÒª°ÑÇ°ÃæµÄÈÕÆÚ½ØÈ¡³öÀ´£¬»òÕ߰ѺóÃæµÄʱ¼ä½ØÈ¡³öÀ´¡£
Õâ¸öʱºò¾ÍÒªÓõ½SQLÀïÃæµÄʱ¼äº¯ÊýÁË£º
select convert(char(10),×Ö¶ÎÃû,108) from ±íÃû
ÉÏÊöÓï¾äÊǽ«ºóÃæµÄʱ¼ä²éѯ³öÀ´£¬¸ñ ......
¡ô1¡¢Ê¹ÓÃË÷ÒýÀ´¸ü¿ìµØ±éÀú±í
ȱʡÇé¿öϽ¨Á¢µÄË÷ÒýÊÇ·ÇȺ¼¯Ë÷Òý£¬µ«ÓÐʱËü²¢²»ÊÇ×î¼ÑµÄ¡£ÔÚ·ÇȺ¼¯Ë÷ÒýÏ£¬Êý¾ÝÔÚÎïÀíÉÏËæ»ú´æ·ÅÔÚÊý¾ÝÒ³ÉÏ¡£ºÏÀíµÄË÷ÒýÉè¼ÆÒª½¨Á¢ÔÚ¶Ô¸÷ÖÖ²éѯµÄ·ÖÎöºÍÔ¤²âÉÏ¡£Ò»°ãÀ´Ëµ£º¢Ù.ÓдóÁ¿Öظ´Öµ¡¢ÇÒ¾³£Óз¶Î§²éѯ£¨between, > ,< £¬> =,< =£©ºÍorder by¡¢group by·¢ÉúµÄÁÐ ......
1.update a set a.nickname=b.nickname from tab1 a,tab2 b where a.username=b.username
2.Update student_score set
student_score.level=level_about.level from
level_about where student.score
between level_about.start_score and level_about.end_score ......