質問

I have seen executing something like this in SQL Server

EXEC (0x53454C45435420312041532054)

or simply like

0x53454C45435420312041532054

Above binary form is equal to SELECT 1 AS T

But I don't remember the exact way how to do this.

Does anyone know executing query like this?

Update:

I know how to convert Binary into Varchar and Varchar into Binary. What I am asking here is how to execute the query in Binary Form?

This is one way,

Declare @q as nvarchar(1000) 
-- 0x530045004C004500430054002000310020004100530020005400 = SELECT 1 AS T
SET @q = CAST(0x530045004C004500430054002000310020004100530020005400 as nvarchar(1000));
EXEC (@q)

Any other way?

役に立ちましたか?

解決

No, I am pretty sure there is no other way to do this. You cannot simply execute binary data.

You can use exec, as you already do, or you could use sp_executesql, but both expect you to pass the query to be executed as a string (NVARCHAR).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top