Stored procedure woes ... inserting binary ...
Posted
by Wardy
on Stack Overflow
See other posts from Stack Overflow
or by Wardy
Published on 2010-05-18T18:24:51Z
Indexed on
2010/05/18
18:30 UTC
Read the original article
Hit count: 296
Ok so I have this storedproc in my SQL 2008 database (works in 2005 too / used to) ...
CREATE PROCEDURE [dbo].[SetBinaryContent]
@Ref nvarchar(50),
@Content varbinary(MAX),
@ObjectID uniqueidentifier
AS
BEGIN
DELETE ObjectContent WHERE ObjectId = @ObjectID AND Ref = @Ref
IF DATALENGTH(@Content) > 5
BEGIN
INSERT INTO ObjectContent
(Ref,BinaryContent,ObjectId)
VALUES
(@Ref,@Content,@ObjectId)
END
UPDATE Objects SET [Status] = 1
WHERE ID = @ObjectID
END
Relatively simple, I take a byte array in C# and chuck it in @Content i then give it a guid and string for the other params and off we go.
...
Great, it used to work ... but it don't anymore ... so erm ... What's wrong with this stored proc?
I've stepped through my C# code thinking I screwed up somehow in that but it definately adds the params and gives them the correct values so what would cause the server to just stop executing this storedproc correctly?
When called this proc executes but nothing changes in the db ... no new records are added to the ObjectContent table.
Weird huh ...
© Stack Overflow or respective owner