Thanks, this does help. I created a second table variable @tables that has the distinct table names
Iterating though that with a WHILE EXISTS( SELECT * from @tables)
SELECT top 1 @tbl = tbl from @tables
and then buidling on my @sqlscript with the Alter Table
and then iterating columns and adding the alter columns statments in a similar inner loop
delete from @tables where tbl like @tbl+'%'
I normally hate the idea of procedural thinking in tsql but this is easy to write and easy to tweak. Once I have the script I can pretty much solder it.
(did I mention I'm REALLY glad you're back <g> )
>Yup, something very similar to that.
>
>Now, once you have a set of the columns, you'd need to parse through them to generate a long script.
>
>Again, I'm more tempted to open up that table that holds the necessary columns through .NET. T-SQL isn't great at this sort of things.... however, you "could" use the T-SQL "for xml" capability. The following example is one I use to show people how to take a bunch of rows and generate a single comma-separated string. This might or might not apply to what you're doing.....but here's an example...
>
>
>declare @ShipMethodIDList nvarchar(1000)
>
>set @ShipMethodIDList =
> stuff ( ( select distinct ',[' +
> cast(ShipMethodID as varchar(100)) + ']'
> from Purchasing.ShipMethod
> for xml path('') ), 1, 1, '')
>
>
>Though again, I'd be more tempted to write a short .NET script (or obviously, a fox script as well)
>
>Again, thinking out loud, but hopefully this helps a bit.
Charles Hankey
Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy
Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.
-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin
Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.