Store a byte[] stored in a SQL XML parameter to a varbinary(MAX) field in SQL Server 2005. Can it be done ?
Here's my stored procedure:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[AddPerson]
@Data AS XML
AS
INSERT INTO Persons (name,image_binary)
SELECT
rowWals.value('./@Name', 'varchar(64)') AS [Name],
rowWals.value('./@ImageBinary', 'varbinary(MAX)') AS [ImageBinary]
FROM
@Data.nodes ('/Data/Names') as b(rowVals)
SELECT SCOPE_IDENTITY() AS Id
In my schema Name is of type String and ImageBinary is o type byte[]. Should I use the String type for ImageBinary too ? Would I then need to specially encode that string somehow ?