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.
| Author |
Topic |
|
Mickybee
Starting Member
29 Posts |
Posted - 2008-05-30 : 08:14:22
|
| Hia,We have a simple table which we need to store logo's for a website. The table looks like this:CLIENTLOGO (Tablename) id (Bigint) (PK) - NOT NULLStoredImage (Image) - NOT NULLImageSize (Integer) - NULLIm not an expert on sql sorry!I have two problems, 1. I need to upload some logo's (they are gif's if thats important)2. I need to store the image sizeI don't have a clue how to do 2 but ive tried the following for 1 but it doesnt seem to workInsert into CLIENTLOGO (id, storedImageTablename)Values (1, 'c:\ClientLogo1.gif')Can somebody help, im really confused about this one |
|
|
eralper
Yak Posting Veteran
66 Posts |
Posted - 2008-05-30 : 08:25:56
|
| Hello MickyBee,You can try the below script which is using OPENROWSETCreate Table EY_EmployeeProfile( EmpId int, EmpName varchar(50) not null, EmpPhoto varbinary(max) not null)GoInsert into EY_EmployeeProfile (EmpId, EmpName, EmpPhoto) Select 1, 'Eralper', BulkColumn from Openrowset( Bulk 'C:\avatar.jpg', Single_Blob) as EmployeePictureAlso if you are looking for an ASP.NET application for file upload and storing the image or any file in SQL Server database, you can find a sample with source codes at [url]http://www.kodyaz.com/articles/file-upload-and-save-to-sql-server.aspx[/url]-------------Eralperhttp://www.kodyaz.com |
 |
|
|
Mickybee
Starting Member
29 Posts |
Posted - 2008-05-30 : 08:51:42
|
| Im not using ASP.NET i simply have new query in sql.I can't change the datatype from Image to varbinary either.Ive tried the following but it doesn't workCLIENTLOGO (Tablename)id (Bigint) (PK) - NOT NULLStoredImage (Image) - NOT NULLImageSize (Integer) - NULLInsert into CLIENTLOGO (id, StoredImage)Select 1, BulkColumn from Openrowset( Bulk 'C:\avatar.jpg', Single_Blob) as StoredImageShould this work |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-05-30 : 09:18:25
|
| Before you spend too much time working that out you should condisder just storing a reference to the filesystem location of the gif file. Then use that reference (path) in the application that will consume this gif.ie:Path varchar(n)filename varchar(n)filesize intBe One with the OptimizerTG |
 |
|
|
Mickybee
Starting Member
29 Posts |
Posted - 2008-05-30 : 09:21:40
|
| Thanks TG.I know that's what people would normally recommend however there are only 6 images and the techy bods want to store them on the server, not sepaate to the server so I must obey |
 |
|
|
|
|
|
|
|