SQL Server - Recuperar arcvivo PDF guardado tipo dato varbinary

 
Vista:
sin imagen de perfil

Recuperar arcvivo PDF guardado tipo dato varbinary

Publicado por Jose Luis (1 intervención) el 05/09/2013 00:04:09
Señores:

Logre almacear un archivo PDF en una tabla con una columna varbinary(max) con INSERT y

SELECT BulkColumn FROM OPENROWSET (BULK 'C:\ejemplo.pdf', SINGLE_BLOB) idocto)

Ahora mi problema es como leer esa columna y volver a generar el archivo PDF en un directorio.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Geri

Recuperar arcvivo PDF guardado tipo dato varbinary

Publicado por Geri (17 intervenciones) el 05/09/2013 07:29:39
1.
Crea un archivo de format con notepad o cualquier otro editor (C:\Tmp\BCP.fmt):
1
2
3
10.0
1
1 SQLBINARY 0 0 "" 1 MiArchivo ""
(el archivo de tener 4 lineas: una vacia en el fin).

2.
Exporta con la siguiente instruccion:
1
Exec XP_CmdShell 'BCP "Select MiArchivo From MiBD.dbo.MiTabla Where ..." Queryout "C:\Tmp\NuevoArchivo.pdf" -T -S localhost -f "C:\Tmp\BCP.fmt"';
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Recuperar arcvivo PDF guardado tipo dato varbinary

Publicado por Cesar (1 intervención) el 03/10/2017 18:57:17
Buenas tardes
Ejecuto desde el sql, ya tengo la carpeta tmb y el archivo .fmt

1
Exec XP_CmdShell 'BCP "Select Campo From BDName.dbo.NameTable where ..." Queryout "C:\tmp\NuevoArchivo2.pdf" -T  -S localhost -f "C:\tmp\BCP.fmt"';

y me sale de error:
Output
SQLState = 08001, NativeError = 2
Error = [Microsoft][ODBC Driver 11 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [2].
SQLState = 08001, NativeError = 2
Error = [Microsoft][ODBC Driver 11 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is config
ured to allow remote connections. For more information see SQL Server Books Online.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired
NULL

les agradecería me puedan ayudar, saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar