Ô¶³Ì±¸·ÝsqlÊý¾Ý¿âµ½±¾»ú
Ìõ¼þ£º
ÓµÓÐsaȨÏÞ
¿ªÆô xp_cmdshell
·½·¨£º
¿ªÆô/¹Ø±Õ xp_cmdshell ±ØÐëÔÚ master ¿âÖ´ÐÐ
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
--ÆôÓÃxp_cmdshell
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'xp_cmdshell', 0
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
--¹Ø±Õxp_cmdshell
±¾µØ¿ªÆôÒ»¸ö¹²ÏíÎļþ¼Ð e.g. document
Ö´ÐÐÓï¾ä --ÒÔÏÂÔÚÒª±¾·Ö¿âÖ´ÐÐ
backup database dbname to disk= 'd:\backdbname.bak ' with init,password= ''
exec xp_cmdshell 'net use z: \\192.168.36.38\document " " /user:des-dev3\rfq '
exec xp_cmdshell 'copy d:\backdbname.bak z:\'
exec xp_cmdshell 'net use z: /delete '
ÔÀí ͨ¹ýsqlÖ¸ÁîÔÚ·þÎñÆ÷½¨Á¢Ò»¸öÍøÂç´ÅÅÌ Ö¸Ïò ±¾»ú¹²ÏíÎļþ¼Ð ·þÎñÆ÷±¸·ÝÊý¾Ý¿âµ½·þÎñÆ÷һĿ¼
ͨ¹ýsql Ö¸Áîcopy ±¸·ÝÎļþµ½ÍøÂç´ÅÅÌ
ɾ³ýÍøÂç´ÅÅÌ
Ïà¹ØÎĵµ£º
Select * from tableName
exec('select * from tableName')
exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
declare @fname varchar(20)
set @fname = 'FiledName'
Select @fname from tableName -- ´íÎó,²»»áÌáʾ´í ......
»ùÓÚSQL Server ·ÖÒ³´æ´¢¹ý³ÌµÄÑݽø ÊÕ²Ø
Õë¶ÔÊý¾Ý¿âÊý¾ÝÔÚUI½çÃæÉϵķÖÒ³ÊÇÀÏÉú³£Ì¸µÄÎÊÌâÁË£¬ÍøÉϺÜÈÝÒ×ÕÒµ½¸÷Ö֓ͨÓô洢¹ý³Ì”´úÂ룬¶øÇÒÓÐЩ»¹¶¨ÖƲéѯÌõ¼þ£¬¿´ÉÏȥʹÓúܷ½±ã¡£±ÊÕß´òËãͨ¹ý±¾ÎÄÒ²À´¼òµ¥Ì¸Ò»Ï»ùÓÚSQL SERVER 2000µÄ·ÖÒ³´æ´¢¹ý³Ì£¬Í¬Ê±Ì¸Ì¸SQL SERVER 2005Ï·ÖÒ³´æ´¢¹ý³ÌµÄÑ ......
½ñÌìÔÚÏîÄ¿ÖÐÓÐÒ»ÎÊÌ⣬ÔÚÍøÉϲéѯÁËcaseµÄÓ÷¨£¬Ìû³öÀ´ºÍ´ó¼Ò·ÖÏíÏ¡£
ÎÊÌâÃèÊö£ºÔÚÒ»ÕűíÖÐÓÐÒ»×Ö¶ÎbitÀàÐÍ£¬±íʾ´ËÌõÊý¾ÝÊÇ·ñ±»Ëø¶¨£¬ÔÚÒ³ÃæÉÏÓÐÒ»°´Å¥ÊǶԴËÌõÊý¾Ý½øÐÐËø¶¨ºÍ½âËøµÄ£¬Ñ¡ÔñÒ³ÃæÖеÄÊý¾Ý£¬µã»÷Õâ¸ö°´Å¥£¬Èç¹ûÕâÌõÊý¾ÝÊÇËø¶¨µÄ£¬¾Í½âËø£»Èç¹ûÊÇδ˵¶¨µÄ¾ÍËø¶¨£¬ÕâÑù¾ÍÓÃÒ»ÌõÓï¾äÀ´ÊµÏÖ¡£ºóÀ´Ï ......
1. ´´½¨ÊÓͼ£º
CREATE OR REPLACE VIEW SM_V_UNIT_AUTH AS
SELECT T2.UNIT_ID,
T2.SUPER_UNIT_ID,
T1.AUTH_ID,
T1.AUTH_NAME,
T1.A ......
COLLATE ÊÇÒ»¸ö×Ӿ䣬¿ÉÓ¦ÓÃÓÚÊý¾Ý¿â¶¨Òå»òÁж¨ÒåÒÔ¶¨ÒåÅÅÐò¹æÔò£¬»òÓ¦ÓÃÓÚ×Ö·û´®±í´ïʽÒÔÓ¦ÓÃÅÅÐò¹æÔòת»»¡£
Óï·¨
COLLATE { <collation_name> | database_default }
<collation_name> :: =
{ Windows_collation_name } | { SQL_collation_name }
²ÎÊý
collation_name
  ......