0

In a stored procedure I must have a varchar variable of max size.

declare @a varchar(max)

This works on SQL Server 2005\08\12 but it doesn't work on 2000.

I don't need that the stored procedure works on SQL Server 2000, I only need that this instruction compile without error.

I have think that a possible solution is something like:

declare @SqlText nvarchar(100) set @SqlText = 'declare @a varchar(max)'
exec sp_executesql @SqlText

But in this way if I try to use the variable @A compiling I get an error that says that I must declare the variable @a.

Is there any possible solution?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dorian
  • 1
  • Do you build database project using SSDT? – qxg Feb 06 '15 at 11:16
  • The answer is already provided in this answer [varchar(max) MS SQL Server 2000, problems?][1], and here, [Max size of varchar(max) in SQL Server 2000][2] [1]: http://stackoverflow.com/a/737791/3021830 [2]: http://stackoverflow.com/a/2077753/3021830 – user3021830 Feb 06 '15 at 11:16

1 Answers1

0

SQL Server 2000 doesn't support VARCHAR(MAX) but you can instead use TEXT which is still supported in SQL Server 2012 (and 2014). It will be removed in the future, but it will work for you now.

DECLARE @a TEXT
DavidG
  • 113,891
  • 12
  • 217
  • 223