sql ×Ö·û´®´¦Àí - MS-SQL Server / Ó¦ÓÃʵÀý
ÓÐÒ»¸ö±íµÄ×Ö¶ÎFileName±£´æÊý¾ÝÊÇ:010101 »ò 100010 »ò 111100 111111 ´ú±í == >> abcdef create table a ( id int not null, FileName varchar(100) not null ) insert into a values(1,'010101') insert into a values(2,'100010 ') insert into a values(3,'111100') Æ©Èç:ÊäÈëÒ»¸ö FileNameµÄֵΪ 010101 --->>b;d;f Èç: select funs('010101') from a; /** b;d;f */ funsÕâ¸öº¯ÊýÒªÇó°ïæµÄ..лл
ÒªÇóдһ¸öº¯Êý ³¤¶ÈÊǹ̶¨µÄ²»£¿ SQL code: case when substing(FileName,1,1)=0 then '' else 'a' end +';'+ case when substing(FileName,2,1)=0 then '' else 'b' end +';'+ case when substing(FileName,3,1)=0 then '' else 'c' end +';'+ ......ÒýÓà SQL code case when substing(FileName,1,1)=0 then '' else 'a' end +';'+ case when substing(FileName,2,1)=0 then '' else 'b' end +';'+ case when substing(FileName,3,1)=0 then '' else 'c' end +';'+ ...¡¡ Õâ¸ö²»ÊÇÎÒÏëÒªµÄ.. ³¤¶È²»¹Ì¶¨µÄ.. ´Ó¡°010101¡± ת»»¡°b;d;f¡±£¬ËûÃǵĹØϵÊÇʲô£¿Èç¹ûÒ»µã¹Øϵ¶¼Ã»ÓУ¬ËüÊÇʲô³öÀ´µÄ£¬²»Ã÷°×£¿ ÊDz»ÊÇÕâ¸ö±í»¹ÓÐÆäËû×ֶΣ¿ ÊÇÓÐÆäËû±í... ÉÏÃæµÄÎÒÖ»ÊǾٸöÀý×Ó... SQL code Code highlighting produced by Actip
Ïà¹ØÎÊ´ð£º
Ö´ÐеÄ˳Ðò£º 1£©Îļþä¯ÀÀ¿ò£¨Ñ¡ÔñÎļþʹÓã© Ñ¡ÔñºÃÎļþºó µã»÷Ò»¸öµ¼Èë°´Å¥µÄʱºò £¬°ÑÉÏÃæÉÏ´«¿òÀïµÄcsvÎļþÒÔÒ»¸öIDΪÎļþÃû£¬ÉÏ´«µ½**/**Îļþ¼ÐÏ 2£©¶ÁÈ¡Õâ¸öÎļþ¼ÐϵÄcsvµÄÎļþ£¬×ª»»³Ésql 3 ......
¿ÉÄÜÒòΪ¹¤×÷µÄÔÒò ½Ó´¥Êý¾Ý¿âÕâ¿é±È½ÏÉÙ£¬Ö®Ç°¶¼ÊÇ×ö³ÌÐòÕâ¿é£¬Êý¾Ý¿âÕâ¿é¶¼ÓÐרÃŵÄÈËÀ´×ö ·Ö¹¤¶¼ºÜÃ÷ϸ ËùÒÔ¶ÔÊý¾Ý¿âÕâÒ»¿éÍêÈ«²»Á˽⡣ǰ¶Îʱ¼ä È¥ÃæÊÔÁ˼¸¼Ò¹«Ë¾ ¼¸ºõ¶¼ÊÇÔÚÊý¾Ý¿âÕâ¿é¹ÒµôµÄ Á¬¸ö¼òµ¥µÄSQ ......
ÏÖÔÚÓÐÒ»¸ö²¿Ãűídept£¨²¿ÃÅÃû³Æ£¬²¿Ãźš£¡££©ÓÐÒ»¸öÈËÔ±±íemp£¨ÐÕÃû£¬ÈËÔ±±àºÅ£¬Ö°Î»£¬Ð½×Ê£¬²¿ÃÅ£© emp±íÖеÄÄÚÈÝÊÇÕâÑùµÄ£º a 1 ¹¤³Ìʦ 3000 Èí¼þ²¿ b 2 ÆÕͨԱ¹¤ 2000 Ó²¼þ²¿ c 3 ¹¤³Ìʦ 4000 Ó²¼þ²¿ d ......
ÎÒÓÐÒ»¸ö×Ö¶ÎÊÇ varchar(1) ÀàÐÍ£¬¶þ½øÖƱíʾҲ¾ÍÊÇ8λµÄ ¡®0000 0000¡¯ ±ÈÈçÕâ¸öʱºòÎÒÐèҪɸѡ³öÕâ¸ö×Ö¶ÎΪËùÓÐµÄ ¡®0000 0100¡¯µÄÐУ¬ÇëÎÊSQLÄÜʵÏÖÕâÑùµÄ¡°Î»¡±µÄɸѡÂ𣿠лл~~~ ÓÐλ²Ù×ݺ¯ÊýÂ𣿲»ÐоÍ× ......