2

I have a Sql server database. Here the Fields are Name, Branch, Age, Image. The Data types of these fields are Varchar,Varchar,Int,Image respectively.

Now I want to insert data into this table manually. It is simple to all fields except Image field. So please suggest me how to insert data into image field manually.

  • 1
    possible duplicate of [How to store image in SQL Server database tables column](http://stackoverflow.com/questions/15659835/how-to-store-image-in-sql-server-database-tables-column) –  Feb 03 '14 at 10:40
  • 1
    @RafalZiolkowski I read the question... I am not asking how to insert data with code. So how it wold be duplicate ? –  Feb 03 '14 at 10:42
  • You are asking how to insert image into SQL table. There is not much code there... than what do you mean by "manually"? by clicking? –  Feb 03 '14 at 10:50
  • 1
    I am not asking on "by clicking" !! I have a datatable . I don't want to insert any data with code. I want to test my code. thats all. so tell me " Can I Insert Image Manually.. Without using any kind of code" ? –  Feb 03 '14 at 10:53
  • what you want to do? manually???? means no code?? or what?? – Pouya Samie Feb 03 '14 at 10:53
  • @PouyaSamie I want to check my another application. Here I am using Image. That is inserted by another way. SO why I code for this. I just want a manual entry.. –  Feb 03 '14 at 10:55
  • Well, at some point any method you'll use will use some code.... I struggle to understand what are you trying to do. –  Feb 03 '14 at 11:03

1 Answers1

1

image field is binary field so you have insert into only binary data so you insert only binary data if you have a image then convert to binary data after insert it

write this

INSERT INTO
    [MyDatabase].[dbo].[tblPicture]
    ( Name, Branch, Age, Image )

    (
        SELECT 'a','amd',1,*
        FROM OPENROWSET
            (BULK N'c:\image.jpg', SINGLE_BLOB)
        AS Picture
    )
pankeel
  • 1,138
  • 1
  • 10
  • 22