sqlÖÐFILENAMEʲôÒâ˼
filename º¯ÊýÔÚ sql Öзµ»ØÎļþ·¾¶ºÍÎļþÃû×Ö·û´®£¬¿ÉÓÃÓÚ»ñÈ¡Îļþ·¾¶¡¢È·¶¨ÎļþÊÇ·ñ±£´æ¡¢½«ÎļþÄÚÈݼÓÔص½±íÖС£
FILENAME ÔÚ SQL ÖеļÄÒå
ÔÚ SQL ÖУ¬FILENAME º¯Êý·µ»ØÎļþ·¾¶ºÍÎļþÃûµÄ×Ö·û´®¡£
Óï·¨£º
FILENAME(<file_expression>)</file_expression>
µÇ¼ºó¸´ÖÆ
ÆäÖУº
ÊÇÒ»¸ö·µ»ØÎļþ·¾¶ºÍÎļþÃûµÄ±í´ïʽ¡£
ʹÓð¸Àý£º
FILENAME º¯Êý¿ÉÓÃÓÚÖ´ÐÐÒÔϲÙ×÷£º
»ñÈ¡ÎļþµÄÍêÕû·¾¶ºÍÎļþÃû¡£
È·¶¨ÎļþÊÇ·ñ±£´æ¡£
½«ÎļþÄÚÈݼÓÔص½±íÖС£
ʾÀý£º
-- »ñÈ¡ÎļþµÄÍêÕû·¾¶ºÍÎļþÃû SELECT FILENAME('my_file.txt'); -- ¼ì²éÎļþÊÇ·ñ±£´æ SELECT CASE WHEN FILENAME('my_file.txt') IS NOT NULL THEN 'File exists' ELSE 'File does not exist' END; -- ½«ÎļþÄÚÈݼÓÔص½±íÖÐ CREATE TABLE my_table AS SELECT * FROM OPENROWSET(BULK 'my_file.csv', FORMAT = 'CSV');
µÇ¼ºó¸´ÖÆ
×¢ÖØÊÂÏ
FILENAME º¯Êý½öÊÊÓÃÓÚÎļþϵͳÖеÄÎļþ¡£
FILENAME º¯Êý·µ»ØµÄÎļþÃû°üÀ¨À©Õ¹Ãû¡£
ÈôÊÇÌṩµÄÎļþ±í´ïʽÎÞЧ£¬FILENAME º¯Êý½«·µ»Ø NULL¡£
ÒÔÉϾÍÊÇsqlÖÐFILENAMEʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡
ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£