The following are the rowset functions available with us to query values from different types of sources.
1. OPENQUERY
2. OPENROWSET
3. OPENDATASOURCE
4. OPENXML
OPENROWSET function support bulk insert operations, Using this we can insert BLOB objects into the database.
1. OPENQUERY
2. OPENROWSET
3. OPENDATASOURCE
4. OPENXML
OPENROWSET function support bulk insert operations, Using this we can insert BLOB objects into the database.
CREATE TABLE [dbo].[TblImage](
[Slno] [int] NOT NULL,
[Image_Data] [image] NULL,
[Image_FileName] Varchar(128),
[Image_Path] Varchar(128))
INSERT INTO TblImage(Slno, Image_FileName, Image_Path, Image_Data)
SELECT '1', 'Jan2012.jpg', 'C:\users\kalyan\desktop',
* FROM OPENROWSET(BULK N'C:\Users\Kalyan\Desktop\Jan2012.jpg', SINGLE_BLOB) as tempImg
INSERT INTO TblImage(Slno, Image_FileName, Image_Path, Image_Data)
SELECT '2', 'Feb2012.jpg', 'C:\users\kalyan\desktop',
* FROM OPENROWSET(BULK N'C:\Users\Kalyan\Desktop\Feb2012.jpg', SINGLE_BLOB) as tempImg
INSERT INTO TblImage(Slno, Image_FileName, Image_Path, Image_Data)
SELECT '2', 'March2012.jpg', 'C:\users\kalyan\desktop', Null
INSERT INTO TblImage(Slno, Image_FileName, Image_Path, Image_Data)
SELECT '4', 'March2012.jpg', 'C:\users\kalyan\desktop',
* FROM OPENROWSET(BULK N'C:\Users\Kalyan\Desktop\April2012.jpg', SINGLE_BLOB) as tempImg
Nice post!!! I just got it to work on my first try! keep up the great work!!!!
ReplyDelete