Store a byte[] stored in a SQL XML parameter to a varbinary(MAX) field in SQL Server 2005. Can it be
- by Mikey John
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[].