how to get image type in nvarchar to be excuted in exec/sp_execute command

  • HI,

    CREATE TABLE #T(I IMAGE)
    INSERT INTO #T VALUES(CAST(N'CREATE PROCEDURE SP1
    @I IMAGE
    AS
    BEGIN
    SELECT ''δΈ‹δΊ›''
    END

    ' AS VARBINARY(MAX)))

    declare @s-2 NVARCHAR(MAX)

    SET @s-2 = (SELECT TOP 1 CAST(CAST(I AS varbinary(MAX)) AS NVARCHAR(MAX)) FROM #T)

    EXEC (@S)

    DROP TABLE #T

    --I want to put storedproc's  text  in image col , then i want to get the text and excute them in database.

     is conversion  and execuation is correct , that is,is there any thing i am missing?

    -- SHOULD I USE SP_EXCUTE insted of exec,BUT I NOTICED I DO NOT HAVE ANY PARAMS.
    pls suggest ?

    --we are planning to change image type but for now , this is the option.

  • Out of curiosity, why do you want to do this?
    😎

  • Eirikur Eiriksson - Saturday, February 18, 2017 2:18 AM

    Out of curiosity, why do you want to do this?
    😎

    it is a sync of ddl, from one database to other database.
    but answer can be given.

  • Image is a deprecated data type.  Why do you want to use it instead of varbinary(max)?

  • rajemessage 14195 - Tuesday, February 21, 2017 10:20 AM

    Eirikur Eiriksson - Saturday, February 18, 2017 2:18 AM

    Out of curiosity, why do you want to do this?
    😎

    it is a sync of ddl, from one database to other database.
    but answer can be given.

    As you chose NOT to effectively answer the question, I can't really justify even looking into whether or not this is practical.  To be honest, this looks more like hacking research... to learn how an attack vector might be easily hidden.   I can't even come up with one single benefit of doing this that doesn't involve hacking research.   Until you can be more forthcoming, I'm not even remotely interested.

    Steve (aka sgmunson) πŸ™‚ πŸ™‚ πŸ™‚
    Rent Servers for Income (picks and shovels strategy)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply