Guys

I need to upload an image on SQL server 2000, I dont want a C# or VB code for that I just wana know if it is possible to just upload a picture straight to SQL server without the insert statemt coz I have loads of images I need to upload to my Database

I have created my table with the ff code now I need to insert an image on the code but I dont know how to do that, any help will be highly appreciated

CREATE TABLE [dbo].[Categories] (
	[CategoryID] [int] IDENTITY (1, 1) NOT NULL ,
	[CategoryName] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[Description] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Picture] [image] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

Try this:

CREATE PROC SaveFileToTable
 @Database  VARCHAR(50),
 @Table  VARCHAR(50),
 @Column  VARCHAR(50),
 @WhereClause  VARCHAR(200),
 @FilePath  VARCHAR(500),
 @Server  VARCHAR(50) = NULL,
 @User    VARCHAR(50) = NULL,
 @Password  VARCHAR(50) = ''
AS
------------------------------------------------------------------------------------------------------------------------------------------------------------
-- This procedure can save the content file to column of IMAGE or TEXT data type
-- Please use this tool (textcopy) with great caution, as it can easily hang the server if parameters are missing
------------------------------------------------------------------------------------------------------------------------------------------------------------
DECLARE @SQL AS VARCHAR(2000)

SET  @Server = COALESCE ( @Server, @@ServerName )
SET  @User = COALESCE ( @User, system_user )

SET  @SQL = 'UPDATE [%s]..[%s] SET [%s] = "" %s'
EXEC master..xp_sprintf @SQL OUTPUT, @SQL, @Database, @Table, @Column, @WhereClause
EXEC (@SQL)

SET  @SQL = 'EXEC master..xp_cmdshell "textcopy /S %s /U %s /P %s /D %s /T %s /C %s /W ""%s"" /F ""%s"" /I"'
EXEC master..xp_sprintf @SQL OUTPUT, @SQL, @Server, @User, @Password, @Database, @Table, @Column, @WhereClause, @FilePath
EXEC (@SQL)





CREATE PROC SaveTableToFile
 @Database  VARCHAR(50),
 @Table  VARCHAR(50),
 @Column  VARCHAR(50),
 @WhereClause  VARCHAR(200),
 @FilePath  VARCHAR(500),
 @Server  VARCHAR(50) = NULL,
 @User    VARCHAR(50) = NULL,
 @Password  VARCHAR(50) = ''
------------------------------------------------------------------------------------------------------------------------------------------------------------
-- This procedure can save the content of IMAGE or TEXT column to a file
-- Please use this tool (textcopy) with great caution, as it can easily hang the server if parameters are missing
------------------------------------------------------------------------------------------------------------------------------------------------------------
AS
DECLARE @SQL AS VARCHAR(2000)

SET  @Server = COALESCE ( @Server, @@ServerName )
SET  @User = COALESCE ( @User, system_user )

SET  @SQL = 'EXEC master..xp_cmdshell "textcopy /S %s /U %s /P %s /D %s /T %s /C %s /W ""%s"" /F ""%s"" /O"'
EXEC master..xp_sprintf @SQL OUTPUT, @SQL, @Server, @User, @Password, @Database, @Table, @Column, @WhereClause, @FilePath
EXEC (@SQL)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.