日期:2014-05-18 浏览次数:20548 次
CREATE TABLE [dbo].[TT] ( [autoid] [int] IDENTITY(1,1) NOT NULL, [photo] [varbinary](max) NULL ); CREATE PROC InsertBigFiles @path nvarchar(50) AS INSERT TT(photo) SELECT photo FROM OPENROWSET(BULK @path,SINGLE_BLOB) AS TT(photo); --上面说@path那里有错 --换成下面的就没有问题,为什么呢 INSERT TT(photo) SELECT photo FROM OPENROWSET(BULK 'c:\r.mpeg',SINGLE_BLOB) AS TT(photo);
CREATE TABLE [dbo].[TT] ( [autoid] [int] IDENTITY(1,1) NOT NULL, [photo] [varbinary](max) NULL ); go CREATE PROC InsertBigFiles @path nvarchar(50) AS exec ('INSERT TT(photo) SELECT photo FROM OPENROWSET(BULK '+@path+',SINGLE_BLOB) AS TT(photo)'); go
------解决方案--------------------
CREATE TABLE [dbo].[TT] ( [autoid] [int] IDENTITY(1,1) NOT NULL, [photo] [varbinary](max) NULL ); go CREATE PROC InsertBigFiles @path nvarchar(50) AS exec ('INSERT TT(photo) SELECT photo FROM OPENROWSET(BULK '''+@path+''',SINGLE_BLOB) AS TT(photo)'); go