Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert documents to a table

Status
Not open for further replies.

ayh8disjob

Programmer
May 31, 2001
41
0
0
SG
Does anyone know how to store an images or documents in the SQL database and retreiving it back?

any tutorial or a sample code would be much appreciated.

Thanks in Advance!!!

 
Look into the READTEXT and WRITETEXT functions in BOL. Although it is possible to store BLOBs in SQL Server, the general consensus is that it is too cumbersome and much easier to store the file path and name in a VarChar column and let the file system store the file itself. --Angel
-----------------------------------
SELECT * FROM users WHERE clue > 0
0 row(s) selected
 
Hi
You can do this using textcopy tool from SQl server. here is the code for that


CREATE PROCEDURE sp_textcopy (
@srvname varchar (30),
@login varchar (30),
@password varchar (30),
@dbname varchar (30),
@tbname varchar (30),
@colname varchar (30),
@filename varchar (30),
@whereclause varchar (40),
@direction char(1))
AS
DECLARE @exec_str varchar (255)
SELECT @exec_str =
'textcopy /S ' + @srvname +
' /U ' + @login +
' /P ' + @password +
' /D ' + @dbname +
' /T ' + @tbname +
' /C ' + @colname +
' /W "' + @whereclause +
'" /F ' + @filename +
' /' + @direction
EXEC master..xp_cmdshell @exec_str

sp_textcopy @srvname = 'sarav-srv',
@login = 'sa',
@password = 'sarav',
@dbname = 'pubs',
@tbname = 'pub_info',
@colname = 'logo',
@filename = 'c:\picture.bmp',
@whereclause = " WHERE pub_id='0877' ",
@direction = 'O'


Sarav2k
 
Hi
You can do this using textcopy tool from SQl server. here is the code for that


CREATE PROCEDURE sp_textcopy (
@srvname varchar (30),
@login varchar (30),
@password varchar (30),
@dbname varchar (30),
@tbname varchar (30),
@colname varchar (30),
@filename varchar (30),
@whereclause varchar (40),
@direction char(1))
AS
DECLARE @exec_str varchar (255)
SELECT @exec_str =
'textcopy /S ' + @srvname +
' /U ' + @login +
' /P ' + @password +
' /D ' + @dbname +
' /T ' + @tbname +
' /C ' + @colname +
' /W "' + @whereclause +
'" /F ' + @filename +
' /' + @direction
EXEC master..xp_cmdshell @exec_str

sp_textcopy @srvname = '',
@login = 'sa',
@password = '',
@dbname = 'pubs',
@tbname = 'pub_info',
@colname = 'logo',
@filename = 'c:\picture.bmp',
@whereclause = " WHERE pub_id='0877' ",
@direction = 'O'


Sarav2k
 
Thanks guys for the help Ive already found a solution.
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top