SQL ServerÎÞ·¨´ò¿ªÓû§Ä¬ÈÏÊý¾Ý¿â
ÎÞ·¨´ò¿ªÓû§Ä¬ÈÏÊý¾Ý¿â£¬µÇ¼ʧ°Ü,ÕâÊÇSQL ServerʹÓÃÕßÊìϤµÄÎÊÌâÖ®Ò»¡£ÔÚʹÓÃÆóÒµ¹ÜÀíÆ÷¡¢²éѯ·ÖÎöÆ÷¡¢¸÷À๤¾ßºÍÓ¦ÓÃÈí¼þµÄʱºò£¬Ö»Òª¹Øϵµ½Á¬½ÓSQL ServerÊý¾Ý¿âµÄʱºò£¬¶¼ÓпÉÄÜ»áÅöµ½´ËÎÊÌâ,ÒýÆð´Ë´íÎó·¢ÉúµÄÔÒò±È½Ï¶à,ÏÂÃæÎÒÃǾÍÀ´Ïêϸ·ÖÎöÒýÆð´ËÎÊÌâµÄÔÒòÒÔ¼°½â¾ö°ì·¨¡£
Ò»¡¢ÔÒò
µÇ¼ÕÊ»§µÄĬÈÏÊý¾Ý¿â±»É¾³ý¡£
¶þ¡¢½â¾ö·½·¨£º
(Ò»)¡¢Ê¹ÓùÜÀíÔ±ÕÊ»§Ð޸ĴËÕÊ»§µÄĬÈÏÊý¾Ý¿â
1¡¢´ò¿ªÆóÒµ¹ÜÀíÆ÷,Õ¹¿ª·þÎñÆ÷×é,È»ºóÕ¹¿ª·þÎñÆ÷
2. Õ¹¿ª"°²È«ÐÔ",Õ¹¿ªµÇ¼£¬ÓÒ»÷ÏàÓ¦µÄµÇ¼ÕÊ»§£¬´Óµ¯³öµÄ²Ëµ¥ÖÐÑ¡Ôñ£¬ÊôÐÔ
3¡¢ÖØÐÂÑ¡Ôñ´ËµÇ¼ÕÊ»§µÄĬÈÏÊý¾Ý¿â
(¶þ)¡¢ÈôûÓÐÆäËû¹ÜÀíÔ±µÇ¼ÕÊ»§£¬ÎÞ·¨ÔÚÆóÒµ¹ÜÀíÆ÷ÀïÐ޸ģ¬Ê¹ÓÃisqlÃüÁîÐй¤¾ß
isql /U"sa" /P"saµÄÃÜÂë" /d"master" /Q"exec sp_defaultdb N'sa', N'master'"
Èç¹ûʹÓÃWindowsÑéÖ¤·½Ê½£¬Ê¹ÓÃÈçÏÂÃüÁîÐУ¬½«Ä¬ÈÏÊý¾Ý¿â¸Ä³É·Ç¶ªÊ§µÄÊý¾Ý¿â£º
isql /E /d"master" /Q"exec sp_defaultdb N'BUILTIN\Administrators', N'master'"
£¨2£©ÓÉÓڸıäÁËϵͳÃÜÂëµ¼ÖÂSQLSErverÎÞ·¨Æô¶¯
½â¾ö°ì·¨ÊÇ£º
µã»÷ÔËÐУ¬¼üÈëservices.msc£¬´ò¿ª·þÎñ³ÌÐò£¬ÕÒµ½SQLSERVERÏîÄ¿£¬Ñ¡ÔñÊôÐÔÏîÖ®¶þ-‘µÇ¼’£¬°ÑµÇ¼ÃÜÂë¸ÄΪ²Ù×÷ϵͳAdministratorÕÊ»§µÇ¼ÃÜÂ룬ÖØÐÂÆô¶¯SQLSErver£¬¼´¿ÉÕý³£Æô¶¯¡£
SQL Server 2005
ÔÚ SQL Server 2005 ÖУ¬¿ÉÒÔʹÓà sqlcmd ʵÓóÌÐò¸ü¸ÄĬÈÏÊý¾Ý¿â¡£Îª´Ë£¬Çë°´ÕÕÏÂÁв½Öè²Ù×÷£º¡ô1. µ¥»÷“¿ªÊ¼”£¬µ¥»÷“ÔËÐД£¬¼üÈë cmd£¬È»ºó°´ Enter¡£
¡ô2. ¸ù¾Ý SQL Server µÇ¼ʹÓõÄÉí·ÝÑéÖ¤ÖÖÀ࣬ÇëʹÓÃÒÔÏ·½·¨Ö®Ò»£º• Èç¹û SQL Server µÇ¼ʹÓà Microsoft Windows Éí·ÝÑéÖ¤Á¬½Óµ½¸ÃʵÀý£¬ÇëÔÚÃüÁîÌáʾ·û´¦¼üÈëÒÔÏÂÄÚÈÝ£¬È»ºó°´ Enter£º
sqlcmd –E -S InstanceName –d master
• Èç¹û SQL Server µÇ¼ʹÓà SQL Server Éí·ÝÑéÖ¤Á¬½Óµ½¸ÃʵÀý£¬ÇëÔÚÃüÁîÌáʾ·û´¦¼üÈëÒÔÏÂÄÚÈÝ£¬È»ºó°´ Enter£º
sqlcmd -S InstanceName -d master -U SQLLogin -P Password
×¢Ò⣺InstanceName ÊÇÒªÁ¬½Óµ½µÄ SQL Server 2005 ʵÀýµÄÃû³ÆµÄռλ·û¡£SQLLogin ÊÇÒÑɾ³ýÆäĬÈÏÊý¾Ý¿âµÄ SQL Server µÇ¼µÄռλ·û¡£Password ÊÇ SQL Server µÇ¼ÃÜÂëµÄռλ·û¡£
¡ô3. ÔÚ sqlcmd Ìáʾ·û´¦£¬¼üÈëÒÔÏÂÄÚÈÝ£¬È»ºó°´ Enter£º
Alter LOGIN SQLLogin WITH DEFAULT_DATABASE = AvailDBName
×¢Ò⣺AvailDBName ÊÇ¿ÉÓÉʵÀýÖÐ SQL Server µÇ¼·ÃÎʵÄÏÖÓÐÊý¾Ý¿âµÄÃû³ÆµÄ
Ïà¹ØÎĵµ£º
---·µ»Ø±í´ïʽÖÐÖ¸¶¨×Ö·ûµÄ¿ªÊ¼Î»ÖÃ
select charindex('c','abcdefg',1)
---Á½¸ö×Ö·ûµÄÖµÖ®²î
select difference('bet','bit')
---×Ö·û×î×ó²àÖ¸¶¨ÊýÄ¿
select left('abcdef',3)
---·µ»Ø×Ö·ûÊý
select len('abcdefg')
--ת»»ÎªÐ¡×Ö·û
select lower('ABCDEFG')
--È¥×ó¿Õ¸ñºó
select ltrim(' &nbs ......
What Is SQL?
SQL (pronounced as the letters S-Q-L or as sequel) is an abbreviation for Structured Query Language. SQL is a language designed specifically for communicating with databases.
Unlike other languages (spoken languages like English, or programming languages like Java or Visual Basic), SQ ......
num_field number(12,2);
±íʾnum_fieldÊÇÒ»¸öÕûÊý²¿·Ö×î¶à10λ¡¢Ð¡Êý²¿·Ö×î¶à2λµÄ±äÁ¿¡£
case.....when Ó÷¨£¨Óëdecode£¨£©×÷ÓúÜÏñ£©
select case zsxm_dm
when '02' then
'Ó ......
1¡¢¿ªÊ¼->³ÌÐò-->Microsoft SQL Server 2005>ÅäÖù¤¾ß->SQL Server Configuration Manager->SQL Server 2005 ÍøÂçÅäÖà ->“xxx£¨ÄúµÄÊý¾Ý¿â£©”µÄÐÒ飬ÈçÏÂͼ
½«“Named Pipes”ºÍ“TCP/IP”µÄ״̬µ÷³É“ÆôÓÔ£¬·½·¨ÊÇÔÚ“Named Pipes”ºÍ“T ......