0

フォルダー内の pdf ファイルのサイズを取得できません。以下のコードはテーブルに null 列を返します。また、ファイル名とサイズの両方を 1 つのテーブルに格納できるかどうかも知りたいと思いました。

  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.
4

1 に答える 1

0

pdf データ型はありません。

DECLARE @pdf pdf

それは VARBINARY または FILESTREAM である必要があります

SQL Server 2005 で画像とドキュメントを格納するためのデータ型

于 2013-07-24T13:57:02.727 に答える