tags:

views:

141

answers:

1

I have a string of length 1,44,000 which has to be passed as a parameter to a stored procedure which is a select query on a table. When a give this is in a query (in c# ) its working fine. But when i pass it as a parameter to stored procedure its not working.

Here is my stored procedure where in i have declared this parameter as NVARCHAR(MAX)

------------------------------------------------------
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

CREATE PROCEDURE [dbo].[ReadItemData](@ItemNames NVARCHAR(MAX),@TimeStamp as DATETIME)

AS

select * from ItemData

where ItemName in (@ItemNames) AND TimeStamp=@TimeStamp

---------------------------------------------------------------------

Here the parameter @ItemNames is a string concatinated with different names such as 'Item1','Item2','Item3'....etc.

Can anyone tell what went wrong here?

Thanks & Regards

Padma

A: 

From the looks of the database syntax it looks like Sql Server, these are the maximum sizes of things in Sql Server.

Bytes per short string column 8,000 

Is probably the limiter.

Although:

Bytes per varchar(max), varbinary(max), xml, text, or image column 2^31-1

(i.e. 2,147,483,647) suggests that Sql Server would handle it but for ado.net.

amelvin
though the size limit is 2^31-1, its not taking this parameter which is given as follows from the code: command.Parameters.Add("@ItemNames",SqlDbType.VarChar).Value=itemNames.ToString();
padmavathi
I don't think that the limiter is Sql Server, in this instance - but ADO.NET. I remember (back in the day) when I was using ADO/VBScript there was a limit of about 8,040 bytes for a recordset - I'll see if I can find a reference, but there may well be a cumulative limit for input or output parameters on ADO.NET
amelvin