| Author |
Topic |
|
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2009-03-02 : 08:55:48
|
| hiI have a stored Proc: How do I use the Openrowset to insert a picture using the spForInsert stored Procedures? ThanksCreate Proc spForInsert@ProdID as int,@ProdPic as Varbinary(max)@Prodinfo as Nvarchar(4000)asINSERT INTO [tblProduct] ([ProdID] ,[ProdPic] ,[Prodinfo])VALUES (@ProdID,@ProdPic, @Prodinfo) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-02 : 09:07:17
|
| From BOLOPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB)MadhivananFailing to plan is Planning to fail |
 |
|
|
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2009-03-02 : 09:15:49
|
| hiAs i am using a stored Procedures, do you meanCreate Proc spForInsert@ProdID as int,@Prodinfo as Nvarchar(4000)asINSERT INTO [tblProduct]([ProdID],[ProdPic],[Prodinfo])VALUES(@ProdID,@OPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB), @Prodinfo)It didn't seems to work? Thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-02 : 09:57:05
|
| Create Proc spForInsert@ProdID as int,@Prodinfo as Nvarchar(4000)asINSERT INTO [tblProduct]([ProdID],[ProdPic],[Prodinfo])SELECT @ProdID,* FROM OPENROWSET(BULK N'Image_path', SINGLE_BLOB) as t, @ProdinfoMadhivananFailing to plan is Planning to fail |
 |
|
|
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2009-03-02 : 10:05:14
|
| hiSorry, it is not able to create the stored proc. The error message was:Msg 156, Level 15, State 1, Procedure spForInsert, Line 6Incorrect syntax near the keyword 'OPENROWSET'. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-02 : 10:14:46
|
| See my edited replyMadhivananFailing to plan is Planning to fail |
 |
|
|
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2009-03-02 : 11:02:26
|
| i am really really sorry for the trouble.It seems that it is not working. Error message is:Msg 1087, Level 16, State 1, Procedure spForInsert, Line 10Must declare the table variable "@Prodinfo". Thanks |
 |
|
|
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2009-03-02 : 20:34:20
|
| hiThanks. I got it work. Thanks again. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-03 : 02:25:40
|
quote: Originally posted by sg2255551 hiThanks. I got it work. Thanks again.
Well. Post the modified codeMadhivananFailing to plan is Planning to fail |
 |
|
|
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2009-03-03 : 05:19:45
|
| hiSince my table structure is ProdID, ProdPic, ProdInfo order. I guess that my insert statement do not necessarily follow that orders of the table structure. So i modify toCreate Proc spForInsert@ProdID as int,@Prodinfo as Nvarchar(4000)asINSERT INTO [tblProduct]([ProdID],[Prodinfo],[ProdPic])SELECT @ProdID, @Prodinfo,* FROM OPENROWSET(BULK N'Image_path', SINGLE_BLOB) as tThanks |
 |
|
|
|