Jump to content

armazenar imagens na base de dados


rjsma
 Share

Recommended Posts

exemplo de como colocar imagens dentro de uma BD SQL para uma tabela FOTOS

--TABELA

CREATE TABLE [dbo].[FOTOS](

[sTAMP] [char](25) NOT NULL DEFAULT ((right(newid(),(12))+left(newid(),(8)))+right(newid(),(5))),

[ARTIGO] [char](25) NOT NULL DEFAULT (''),

[iMAGEM] [image] NOT NULL DEFAULT (''),

[PATH] [char](254) NOT NULL DEFAULT (''))

--INSERIR DADOS NA TABELA

INSERT INTO FOTOS

SELECT 'STAMP' STAMP, '123456789' ARTIGO ,''IMAGEM,'' PATH

--PROCEDURE

CREATE PROCEDURE IMPORTAR_JPG

@ARTIGO VARCHAR(25)

AS

DECLARE @SQL VARCHAR(300),

@SERVIDOR  VARCHAR(25),

@BASEDADOS VARCHAR(25),

@USER      VARCHAR(25),

@PASSWORD  VARCHAR(25),

@CAMINHO    VARCHAR(100)

       

SET @SERVIDOR    =          'SERVER'

SET @BASEDADOS =          'SERVER'

SET @USER  =    'SA'

SET @PASSWORD  =          'password'

SET @CAMINHO    =          '\\SERVER\IMAGENS\'

SET @SQL='C:\TEXTCOPY /S"' + RTRIM(@SERVIDOR) + '" /U"' + RTRIM(@USER)

        + '" /P"' + RTRIM(@PASSWORD) + '" /D"' + RTRIM(@BASEDADOS)

        + '" /T"FOTOS" /C"IMAGEM" /W"WHERE ARTIGO=''' + RTRIM(@ARTIGO)

        + '''" /F"'+ RTRIM(@CAMINHO) + RTRIM(@ARTIGO) + '.JPG " /I /Z'

EXEC MASTER..XP_CMDSHELL @SQL ,NO_OUTPUT

UPDATE FOTOS SET

PATH=RTRIM(@CAMINHO) + RTRIM(@ARTIGO) + '.JPG'

WHERE

ARTIGO=@ARTIGO

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.