May 22, 2007 at 8:32 am
HI Guys,
What data type field we can use to store a PDF file in SQL DB.
A sample will help a lot.
Thanks is advance.
May 22, 2007 at 8:59 am
May 23, 2007 at 12:42 am
An Image column is fine, this sample should work if you replace the path to Textcopy.exe with the one where your sql server 2000 is installed
The unfortunate thing about this solution is that you have to write the db userid and password in plain text in your sql code.
At the end, you replace the filename part with the UNC path to your pdf file, and the where clause to identifiy the unique table row the file needs to be stored in.
DECLARE @cmd_line nvarchar(4000)
SET @cmd_line = 'c:\Progra~1\Micros~1\MSSQL\Binn\'
SET @cmd_line = @cmd_line + 'TextCopy.exe /S . /U <userid> /P <password> /D <databasename> /T <tablename> /C <Column Name> '
SET @cmd_line = @cmd_line + '/F "c:\test.pdf" /W "WHERE ID = 25" /I '
EXEC master..xp_cmdshell @cmd_line , no_output
May 23, 2007 at 3:11 am
Hi,
I had never heard about this .exe before. It is defineatly one I will look into more.
I did a search for it on google and came across this link
http://www.databasejournal.com/features/mssql/article.php/1443521
It has a nice way of using TextCopy via an SP. An if you wish to be more secure you can encryted your SP so that your Username and Password are not exposed.
Its something I had to do when I wanted to called DTS Packages from an SP where I had to enter a high privileged Username and Password
Darren
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply