SQL Server Bulk Import catalog file _mssql

Source: Internet
Author: User
OpenRowset usage can refer to the MSDN
Http://technet.microsoft.com/zh-cn/library/ms190312.aspx
If there are many files, it is recommended to use the program to pour
Copy Code code as follows:

if (object_id (' T_bulkresult ') is not null)
drop table T_bulkresult
CREATE TABLE T_bulkresult (name varchar (1000), data image)
Go
DECLARE @d varchar (1000)
Set @d = ' c:\test\ '
CREATE TABLE #tb (FName varchar (1000), d int, F int)
INSERT INTO #tb exec xp_dirtree @d, 1, 1
Delete from #tb where F <> 1
DECLARE @ SQL nvarchar (max)
SELECT @ sql = ISNULL (@ SQL, ') + ' insert into T_bulkresult select ' ' +@d + fname + ' ", * FROM OPENROWSET (BULK N '" ' +@ D + fName + ' ", Single_blob) b
'
From #tb A
EXEC sp_executesql @ sql
drop table #tb
SELECT * FROM T_bulkresult
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.