0
CREATE TABLE Kitaplar
(
Id INT NOT NULL,
Isim NVARCHAR(50) NOT NULL,
Yazar NVARCHAR(50) NOT NULL,
Resim IMAGE,
Alinis_Tarihi DATE,
Verilis_Tarihi DATE,
PRIMARY KEY (Id)
)

I have this table and I want to create an instance.

insert into Kitaplar values 
  (003, 'Forty Thorns','Judy Lighy Ayyildiz',null,2012-01-01,2012-02-01)

it doesn't accept these date types.

How should I insert that? And how can I add an image?

I'm using SQL Server 2008 Express.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Anıl Canlı
  • 432
  • 9
  • 20

1 Answers1

1

You need to enclose the dates in quotes as follows:

Insert into Kitaplar values (003, 'Forty Thorns','Judy Lighy Ayyildiz',null,'2012-01-01','2012-02-01')

As far as adding the image, something like this would work (there are other ways to do this too):

Update myTable
Set Image = (SELECT *
   FROM OPENROWSET(BULK N'C:\MyImage.jpg', SINGLE_BLOB) test)
   Where MyColumn = TargetValue
Randy Minder
  • 47,200
  • 49
  • 204
  • 358