¹ØÓÚSQL²éѯÓï¾äÀïÃæ½Øȡʱ¼äµÄº¯ÊýÈô¸É
ÓÐЩʱºòÎÒÃÇÐèÒª²éѯÊý¾Ý¿âÖеÄʱ¼ä×ֶΣ¬ÀýÈç2009-11-11 11:11:11:111 ÕâÑùµÄʱ¼ä¸ñʽ¡£
¶øÎÒÃÇÓÐЩʱºò²»ÓðÑÕû¸öµÄ×ֶβéѯ³öÀ´£¬ÐèÒª°ÑÇ°ÃæµÄÈÕÆÚ½ØÈ¡³öÀ´£¬»òÕ߰ѺóÃæµÄʱ¼ä½ØÈ¡³öÀ´¡£
Õâ¸öʱºò¾ÍÒªÓõ½SQLÀïÃæµÄʱ¼äº¯ÊýÁË£º
select convert(char(10),×Ö¶ÎÃû,108) from ±íÃû
ÉÏÊöÓï¾äÊǽ«ºóÃæµÄʱ¼ä²éѯ³öÀ´£¬¸ñʽΪ11:11:11¡£
convert()ºóÃæµÄ²ÎÊýÓÐÈý¸ö£¬µÚÒ»¸öÊdz¤¶È£¬µÚ¶þ¸öÊÇÒª½ØÈ¡µÄ×Ö¶ÎÃû£¬µÚÈý¸öÊÇʱ¼äÏÔʾµÄ¸ñʽ£¬µÚÈý¸ö²ÎÊý¿ÉÒÔ¸ù¾ÝÐèÒª¸Ä±ä¡£
µ±ÎÒÃÇÒª½ØÈ¡Ç°ÃæµÄ2009-11-11µÄʱºò°Ñ108¸Ä³É120¼´¿É¡£
ÒÀ´ÎÀàÍÆ£¬Ïêϸ½éÉܿɼûSQLµÄÁª»ú°ïÖúÎĵµ£¬ÊäÈëconvert¼ìË÷¼´¿É¡£
Ïà¹ØÎĵµ£º
¡¡¡¡ÈÕÇ°SQL INJECTIONµÄ¹¥»÷²âÊÔÓúÑÝÓúÁÒ£¬ºÜ¶à´óÐ͵ÄÍøÕ¾ºÍÂÛ̳¶¼Ïà¼Ì±»×¢Èë¡£ÕâЩÍøÕ¾Ò»°ãʹÓõĶàΪSQL SERVERÊý¾Ý¿â£¬ÕýÒòΪÈç´Ë£¬ºÜ¶àÈË¿ªÊ¼»³ÒÉSQL SERVERµÄ°²È«ÐÔ¡£ÆäʵSQL SERVER 2000ÒѾͨ¹ýÁËÃÀ¹úÕþ¸®µÄC2¼¶°²È«ÈÏÖ¤-ÕâÊǸÃÐÐÒµËùÄÜÓµÓеÄ×î¸ßÈÏÖ¤¼¶±ð£¬ËùÒÔʹÓÃSQL SERVER»¹ÊÇÏ൱µÄ°²È«µÄ¡£µ±È»ºÍORCAL¡¢DB2µ ......
Êý¾ÝÔ´......°üº¬ÎÞ·¨ÓÃÓÚ´¦Àí²Ù×÷µÄ ImpersonationMode¡£
½â¾ö·½·¨£º
·þÎñÆ÷Á¬½Ó¸ÄΪ“ʹÓ÷þÎñÕË»§”¡£
¾ßÌå²Ù×÷£º
ÔÚÊý¾ÝÔ´ÀïµÄÏîÄ¿Éϵã»÷ÓÒ¼ü->´ò¿ª->Êý¾ÝÔ´Éè¼ÆÆ÷ £¬ Ñ¡Ôñ“Ä£ÄâÐÅÏ¢”±êÇ©->Ñ¡Ôñ“ʹÓ÷þÎñÕË»§”£¬È·¶¨£¬Ö´Ðв¿Êð¡£ ......
¡¡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
¡ ......
±í½á¹¹ºÍÊý¾ÝÈçÏ£¨±íÃûTest£©£º
NO VALUE NAME
1 a ²âÊÔ1
1 b ²âÊÔ2
1 c ......
1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃexecÖ´ÐÐ
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 tab ......