Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Test Image Data

Author  Topic 

mlawton40
Starting Member

15 Posts

Posted - 2007-02-28 : 07:56:58
Hi I have the following table and just wondered if theres an easy way of inserting test data with the image field not null?

Table: file
Fields: file_id(int), filename(varchar), data(image).

Any help would be great!
Cheers, Mark

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-28 : 08:03:53
INSERT File (File_ID, FileName, Data)
SELECT 1, 'TestFile', 0x0


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

mlawton40
Starting Member

15 Posts

Posted - 2007-02-28 : 10:15:58
quote:
Originally posted by Peso

INSERT File (File_ID, FileName, Data)
SELECT 1, 'TestFile', 0x0


Peter Larsson
Helsingborg, Sweden



Hi thanks for the reply but I have tried this and I didn't think it would work and hasn't. Why the select statement?

I have done:

INSERT file (fileName, description, filetype, doc_area, data, modified_by, modified_date)
SELECT 'TestFile', 'descript', '.doc', 133, 0x0, 'webteam', '27/02/2007'

to try and insert test data and it displays the error: Incorrect syntax near the keyword 'file'.

Cheers, Mark
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-28 : 10:17:53
Maybe because File is a reserved word in SQL Server?
INSERT [file] (fileName, description, filetype, doc_area, data, modified_by, modified_date)
SELECT 'TestFile', 'descript', '.doc', 133, 0x0, 'webteam', '27/02/2007'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

mlawton40
Starting Member

15 Posts

Posted - 2007-02-28 : 10:30:08
quote:
Originally posted by Peso

Maybe because File is a reserved word in SQL Server?
INSERT [file] (fileName, description, filetype, doc_area, data, modified_by, modified_date)
SELECT 'TestFile', 'descript', '.doc', 133, 0x0, 'webteam', '27/02/2007'


Peter Larsson
Helsingborg, Sweden



Ok, thanks for that. I now have the error: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.

So have tried:
INSERT [file] (fileName, description, filetype, doc_area, data, modified_by, modified_date)
SELECT 'TestFile', 'descript', '.doc', 133, 0x0, 'webteam', '27/02/2007 09:44:04'

but still have the same problem. Any thoughts?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-28 : 10:33:07
Well, there is no month 27 in the world, I think.
Always use ISO date format standard when entering hardcoded dates.

INSERT [file] (fileName, description, filetype, doc_area, data, modified_by, modified_date)
SELECT 'TestFile', 'descript', '.doc', 133, 0x0, 'webteam', '20070227 09:44:04'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-28 : 10:33:33
Or add to the top of query

SET DATEFORMAT dmy


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -