I want to use an Execute SQL Task
query to return varbinary
data from a database table. The query requires a UniqueIdentifier
as a parameter which is stored as string
in a Package variable. The result of this query (the varbinary data) will be stored in a second variable of type Byte.
The table below shows my list of local variables, note that DocumentGuid is pre-populated by another part of control flow
| Variable Name | Qualified Name | Scope | Data Type | Comments |
|---------------|--------------------|---------|-----------|------------------------------------------|
| DocumentGuid | User::DocumentGuid | Package | String | Used to store a GUID value |
| DocumentData | User::DocumentData | Package | Byte | Used to hold varbinary data from a query |
When I try to use this in a Execute SQL Task
query like this:
SELECT DocData
FROM docsRepo
WHERE DocumentGuid = ?
Passing in the parameters as
| Variable name | Direction | Data Type | Parameter Name | Parameter Size |
|--------------------|-----------|-----------|----------------|----------------|
| User::DocumentGuid | Input | GUID | 0 | 100 |
And Result Set
| Result Name | Variable Name |
|-------------|--------------------|
| DocData | User::DocumentData |
I get the following error:
[Execute SQL Task] Error: Executing the query "SELECT DocData FROM
dbo.docsRepo..." failed with the following error: "Conversion failed when converting from a character string to uniqueidentifier.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Am I missing some kind of fundamental logic here? The following script works just fine in SQL Server:
SELECT DocData
FROM docsRepo
WHERE DocumentGuid = '53A394A7-5D2B-40C0-A04D-90553E4535C3'