I need to build a dynamic string of SQL that can be very long (it's
actually creating a view dynamically based on values in a table). The
problem is, this SQL can very easily go over 8000 characters that a
varchar variable can hold.
How can I dynamically build up a long sql statement in a string variable
and EXEC it, if it's possible the string value will be longer than 8000
characters?
I can't declare local variables of type text. The solution has to work
on both SQL2000 and SQL2005. I'm at a loss here. Help?
MS Sql Server LazyDBA home page