无法检索文件夹中 pdf 文件的大小,下面的代码在表中返回一个空列,我还想知道我是否可以将文件名和大小都存储在它自己的一个表中。
Create table #PDFFiles
(
PDFFile varchar(300)
)
Declare @param as varchar(100)
Declare @Path as varchar(1000)
Declare @PreparedBatch as Nvarchar(max);
Set @PreparedBatch =
'DECLARE @pdf pdf
SELECT @pdf = CAST(BulkColumn AS pdf)
FROM OPENROWSET(BULK ''?'', SINGLE_BLOB) AS x
INSERT dbo.PDFDocument (PDFdoc)
SELECT @pdf;';
Set @Path = 'C:\dump\'
Set @param = 'dir ' + @Path + '*.pdf /b'
Insert into #PDFFiles
Exec master..xp_cmdshell @param
Update #PDFFiles Set PDFFile = @Path + PDFFile
While Exists(select * from #PDFFiles where PDFFile is not null)
Begin
Declare @CurrentFile Table (PDFFile varchar(300));
Delete Top (1) from #PDFFiles
OUTPUT DELETED.PDFFile INTO @CurrentFile
Where PDFFile is not null
Declare @Batch as Varchar(max)
Select @Batch = Replace(@PreparedBatch,'?',PDFFile) from @CurrentFile
Exec (@Batch)
Delete from @CurrentFile
End
这是我在运行此代码时遇到的错误
Column, parameter, or variable #1: Cannot find data type pdf.
Parameter or variable '@pdf' has an invalid data type.