SQL Server VARBINARY(MAX)

2k views Asked by At

I have a stored procedure that inserts a varchar & VARBINARY(MAX) values in the table. I pass a c# byte[] to the varbinary(max) field. I also see that the size of the byte[] size is 80142 which satisfies the max limit of varbinary. Stored procedure executes without any errors. But when I try to query that table I see empty values in the varbinary datatype.

SQL sp

 ALTER PROCEDURE [dbo].[Test] 
            -- Add the parameters for the stored procedure here
            @PNumber varchar(50)
            ,@Byte varbinary(max)
        AS
        BEGIN
            SET NOCOUNT ON;

            -- Insert statements for procedure here
            INSERT INTO [Test].[dbo].[Data]
                   ([PNumber]
                   ,[PByte])
             VALUES
                   (@PNumber
                   ,@Byte)
        END

C# CODE

byte[] theData = doc.GetData();

DAL_DataTableAdapters.QueriesTableAdapter qta = new DAL_DataTableAdapters.QueriesTableAdapter();

qta.Test("test", theData);

Table structure:

CREATE TABLE [dbo].[Data]
(
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [PNumber] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [PByte] [varbinary](max) NULL
) ON [PRIMARY]
1

There are 1 answers

2
erikkallen On BEST ANSWER

How do you determine that the data is empty? I'm quite certain that SQL Server Management Studio will not display a value that is too long (I don't know the limit), even when the value is there.