I am trying to update a database that contains 40+ different sets of tables (each set has a unique tableowner).

I have a full alter script written to perform the update, but I do not want to have to manually code the variable for the tableowner into my DTS package for each of these tableowners.

I have managed to script it to the point where it checks properly and will insert a variable for the tableowner - the only problem is that the script itself is huge (28,000+ lines) and I need an unlimited type because I'm basically trying to declare the entire script as a second variable and then execute it.

Basically what I am doing is this:

I first load all the variables I plan to use for @tbowner into a temp table into a field called tableowner. Then I'm trying to somehow incorporate the following into a SPROC or something similar:

-------------------------------------
declare @tbowner varchar (10)
declare @alter text

select top 1 tableowner from ##temp
set @alter = (alter script with embedded @tbowner variable throughout)
exec (@alter)
-------------------------------------

upon completion I would delete top 1 from ##temp and then loop the process around until ##temp is empty

Naturally SQL tells me that text, ntext and image are not valid for local variables - does anyone have any other suggestions or routes to try?

Thanks in advance!
Dirk