SQL Server 2005 ¾µÏñ¹¹½¨ÊÖ²á
Ò»¡¢ ¾µÏñ¼ò½é
1¡¢ ¼ò½é
Êý¾Ý¿â¾µÏñÊǽ«Êý¾Ý¿âÊÂÎñ´¦Àí´ÓÒ»¸öSQL ServerÊý¾Ý¿âÒƶ¯µ½²»Í¬SQL Server»·¾³ÖеÄÁíÒ»¸öSQL ServerÊý¾Ý¿âÖС£¾µÏñ²»ÄÜÖ±½Ó·ÃÎÊ;ËüÖ»ÓÃÔÚ´íÎó»Ö¸´µÄÇé¿öϲſÉÒÔ±»·ÃÎÊ¡£
Òª½øÐÐÊý¾Ý¿â¾µÏñËùÐèµÄ×îСÐèÇó°üÀ¨ÁËÁ½¸ö²»Í¬µÄSQL ServerÔËÐл·¾³¡£Ö÷·þÎñÆ÷±»³ÆΪ“Ö÷»ú”£¬µÚ¶þ¸ö·þÎñÆ÷±»³Æ×÷“±¸»ú”¡£Ö÷»úÊý¾Ý¿â¾ÍÊÇÄãʵ¼ÊÓÃ×ŵÄÊý¾Ý¿â£¬¾µÏñÊý¾Ý¿â¾ÍÊÇÄãµÄÊý¾Ý¿âµÄ±¸Óÿ½±´¡£µ±ÊÂÎñдÈëÄãµÄ»ù±¾·þÎñÆ÷µÄʱºò£¬ËûÃÇҲͬÑù±»´«Ë͵½²¢Ð´ÈëÄãµÄ¾µÏñÊý¾Ý¿âÖС£
³ýÁË»ù±¾ºÍ¾µÏñÖ®Í⣬Ä㻹¿ÉÒÔÒýÈëÁíÒ»¸ö¿ÉÑ¡µÄ×é¼þ£¬ÃûΪ“¼ûÖ¤”¡£¼ûÖ¤·þÎñÆ÷ÊǵÚÈý¸öSQL Server 2005ÔËÐÐʵÀý£¬ËüÊÇÔÚÅжÏʲôʱºò½øÐдíÎó»Ö¸´µÄʱºò£¬ÓÃÓÚ»ù±¾ºÍ¾µÏñÖ®¼äÄÚ²¿½»Á÷¡£Ö»Óе±ÄãÏëʵÏÖ×Ô¶¯´íÎó»Ö¸´µÄʱºòÓõ½Õâ¸öÑ¡Ïî¡£ËüʵÏÖÁË2±È1ͶƱµÄÄÜÁ¦£¬µ±ÎÒµÄÒ»¸ö×é¼þ²»¿É´ï£¬²¢Òò´ËÐèÒª½øÐдíÎó»Ö¸´µÄʱºò¡£¼ûÖ¤·þÎñÆ÷Ö»ÓÐÔÚÄãÏëʵÏÖ×Ô¶¯´íÎó»Ö¸´µÄʱºò²ÅÐèÒªÓõ½¡£
2¡¢ Óŵã
ϱíÊÇSQL Server¿ÉÓÃÐÔ¹Ù·½½â¾ö·½°¸µÄÒ»¸ö¶ÔÕÕ±í£¬ÏÖʱÎÒÖÐÐÄʹÓõĻָ´Ä£Ê½ÊÇ“À䱸·Ý”Öеē±¸·Ý/»Ö¸´”£¬Í¨³£À´Ëµ“Èȱ¸·Ý”±È“À䱸·Ý”µÄ¿ÉÓÃÐÔ¸ü¸ß£¬»Ö¸´¸ü¿ì£¬¸üÊʺÏÎÒÖÐÐÄÏÖʱµÄʵ¼ÊÇé¿ö¡£Èç¹û²»´Ó³É±¾¿¼ÂǵĻ°£¬“Èȱ¸·Ý”Öеē¹ÊÕÏתÒÆȺ¼¯”µÄ¿ÉÓÃÐÔÊÇ×î¸ßµÄ£¬µ«ÊǹÊÕÏתÒÆȺ¼¯ÐèÒª½èÖú´ÅÅÌÕóÁжøÇÒ½¨Éè±¾Éí¸´ÔÓÐԽϸߡ£Êý¾Ý¿â¾µÏñµÄ½¨Á¢²¢Ã»ÓÐÌ«¶àµÄÓ²¼þÒªÇó£¬×îÆðÂëûÓÐÏñ“¹ÊÕÏתÒÆȺ¼¯”ÐèÒª¹²Ïí´æ´¢Õâô¸ßµÄÒªÇó¡£
2¡¢ ȱµã
£¨1£©ÓÉÓÚSQL ServerÊÇÒ»¸öʵÀý¶à¸öÊý¾Ý¿âµÄ²úÆ·£¬Êý¾Ý¿â¾µÏñ¼¼ÊõÊÇ»ùÓÚÊý¾Ý¿â¼¶±ðµÄ£¬Òò´Ëÿ´ÎÖ÷Êý¾Ý¿âÐÂÔöÊý¾Ý¿â¶¼±ØÐëΪ±¸»úÔö¼ÓÊý¾Ý¿â²¢ÇÒΪÐÂÔöµÄÊý¾Ý¿â½¨Á¢¾µÏñ¹Øϵ¡£
£¨2£©Êý¾Ý¿âµÄµÇ¼ÃûºÍÓû§ÊÇ´æ´¢ÔÚmasterÊý¾Ý¿â£¬masterÊý¾Ý¿âÊDz»ÄÜ×ö¾µÏñµÄ£¬ËùÒÔÿ´Î²Ù×÷Êý¾Ý¿âµÄµÇ¼ÃûºÍÓû§Ò²ÊÇÐèÒª¶àά»¤Ò»·Ý£¬
£¨3£©Êý¾Ý¿â×÷Òµ²»Äܵõ½ÏàÓ¦µÄά»¤¡£
£¨4£©Î¢ÈíºÅ³Æ¾µÏñ¿ÉÒÔÈÿͻ§¶Ë¶Ô¹ÊÕÏ͸Ã÷£¬µ«ÊÇʵ¼Ê²âÊÔÖз¢ÏÖÖ»ÓÐÂú×ãÌض¨µÄÌõ¼þ²ÅÄÜʵÏÖ͸Ã÷»¯£¬¶øÇÒ͸Ã÷»¯µÃ¿Í»§¶ËÖ§³Ö²Å¿ÉÐУ¨.net Framework 2.0ÒÔÉÏ£¬Microsoft jdbcÇý¶¯ 1.1ÒÔÉÏ£©¡£
£¨5£©¿çÊý¾Ý¿âÊÂÎñºÍ·Ö²¼Ê½ÊÂÎñ¾ù²»Ö§³ÖÊý¾Ý¿â¾µÏñ¡£
×ݹÛÆäËû¼¸ÖÖ·½Ê½£¬½öÓГÈȱ¸·Ý”µÄ“¹ÊÕÏתÒÆȺ¼¯”ûÓÐÕâЩÎÊÌâ¡£
Ò»¡¢ÅäÖÃÖ÷±¸»ú
1¡¢ ÎïÀíÁ¬½Ó
Ïà¹ØÎĵµ£º
½«ÁÐת»»ÎªÐУ¬Ï൱ÓÚ½«±í½á¹¹Ðýת90¶È
T_Student ±í
Stud_ID
Sex
Name
1
ÄÐ
Tom
2
Å®
Anne
3
ÄÐ
Jack
Ö´ÐÐ: Exec proColumnToRow ’T_Student’,’Name’,’ New_ID’
ת»»ºóµÄ±í
New_ID
Tom
Anne
Jack
Stud_ID
1
2
3
Sex
ÄÐ
Å®
ÄÐ
& ......
ÏÂÃæÌá³öÁË10ÌõºÍDB2 SQLÐÔÄÜÏà¹ØµÄ10ÌõÒòËØ£º
1¡¢ÌṩÊʵ±µÄͳ¼ÆÐÅÏ¢
¶ÔDB2ÓÅ»¯¹ÜÀíÆ÷£¨otimizer£©¶øÑÔ£¬ÈçºÎ¸ü¼ÓÓÐЧµÄÖ´ÐÐSQLÓï¾äÊÇÓÉ´æÔÚÓÚDB2 catalogÖеÄͳ¼ÆÐÅÏ¢¾ö¶¨µÄ£¬ÓÅ»¯Æ÷ÀûÓÃÕâЩÐÅÏ¢¾ö¶¨×îÓÅ»¯µÄ·¾¶¡£
Òò´Ë£¬ÎªÁ˱£³ÖϵͳÄܹ»×ö³ö×î¼ÑÑ¡Ôñ£¬ÐèÒª¾³£µÄÔËÐÐRunstatsÃüÁÀ´±£³Öϵͳͳ¼ÆÐÅÏ¢µÄ¼°Ê±ÓÐЧ¡£ ......
ÈçºÎʵÏÖ¶à¸ö¹Ø¼ü×Ö°´ÕÕ²»Í¬ÅÅÐò¹æÔò½øÐÐÅÅÐòÄØ£¿
ORDER BY×Ó¾äÈÃÊý¾Ý¿â¶Ô²éѯ½á¹ûÅÅÐò£¬ORDER BY×Ó¾ä±ØÐë·ÅÔÚ²éѯÓï¾äµÄ½áβ¡£Æä»ù±¾ÓÃ
·¨ÈçÏ£º
SELECT * from Contacts ORDER BY first_name;
Äã¿ÉÒÔ¶Ô¶àÁÐÊý¾ÝÅÅÐò¡£ÓÅÏÈ˳Ðò°´´Ó×óµ½ÓÒÒÀ´Î½µµÍ£¬ËùÒÔ²éѯÓï¾äÖ ......
LIKE ²Ù×÷·ûÓÃÓÚÔÚ WHERE ×Ó¾äÖÐËÑË÷ÁÐÖеÄÖ¸¶¨Ä£Ê½¡£
SQL LIKE ²Ù×÷·ûÓï·¨
SELECT column_name(s) from table_name WHERE column_name LIKE pattern
SQL ͨÅä·û
ÔÚËÑË÷Êý¾Ý¿âÖеÄÊý¾Ýʱ£¬SQL ͨÅä·û¿ÉÒÔÌæ´úÒ»¸ö»ò¶à¸ö×Ö·û¡£
SQL ͨÅä·û±ØÐëÓë LIKE ÔËËã·ûÒ»ÆðʹÓá£
ÔÚ SQL ÖУ¬¿ÉʹÓÃÒÔÏÂͨÅä·û£º
ͨÅä·û
Ãè ......
ÓÉÓÚ³ÌÐòÐèÒª°ÑSQL SERVER ÀïµÄÊý¾Ýµ¼Èëµ½ACCESSÀï.
¸Õ¿ªÊ¼Ê¹ÓÃDataSetÀ´Ñ»·.
Êý¾ÝÁ¿ÉÙµÄʱºò»¹Ëã¿ÉÒÔÓ¦¸¶µÄ¹ýÀ´.
µ«µ±Êý¾Ý¶àµÄʱºò.
»á±¨´í"λÖôíÎó"
ÔÚÍøÉÏËÑÑ°Ò»·¬.ÕÒµ½Ò»¸ö·½·¨.
ʹÓÃinsert into openrowset
½Ó×Å´íÎóÒ»¸ö½ÓÒ»¸öµÄÀ´..
"²åÈë´íÎó: ÁÐÃû»òËùÌṩֵµÄÊýÄ¿Óë±í¶¨Ò岻ƥÅä¡£"
"δÄÜÕÒµ½ OLE DB Ì ......