Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating custom data types?

Status
Not open for further replies.

x6213

Programmer
Aug 17, 2005
17
US
Somehow all of the user defined data types and some of the lengths have been changed to the sql default datatypes in every column in one of our databases. I think it was caused by a conflicting software that shares the sql database. No one wants to take responsibility for this, but and I have the fun job of putting everything back.
Using a backup isn't a solution, since these changes happened months ago and haven't been noticed till now.
So I have to manually fix this ... :(
The problem is there is over 300 tables with roughly 100 columns in each.
any suggestions or advice?
 
> Somehow all of the user defined data types and some of the lengths have been changed to the sql default datatypes in every column in one of our databases.

Strange... once bound, user-defined types are hard to change/remove.

How about some "before/after" examples?

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Vongrunt, the correct one is the one on the right
untitled16nw.gif


SQLDenis, since this happened months ago, all current backups are like this.
all I have is a really old sample database(from 2001!) to compare with.
 
Hm... many things could do that.

For example, SELECT INTO does not copy UDTs; it generates original datatypes in target table (varchar(40) instead of T_VARCHAR_40)

DTS export/import wizard: Copy tables option will do that, but Copy objects won't.

I've also seen some 3rdparty tools/custom-made scripts that rely on INFORMATION_SCHEMA.COLUMNS.DATA_TYPE column instead of DOMAIN_NAME. Same effect.

Btw. is there any pattern/correlation between affected tables and their creation dates/times (use EM or sysobjects.crdate to check that)?

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
ok, it looks like the problem might have been caused when someone truncated the log file because of storage space issues a few months back.

I have tried the compare utility and it works great. but I'll have to run 900 sql scripts :( 300, for each table and three times each (one on a remote test system, one on an image of the server, and one on the actual server)

Is there a way that I can batch run the 300 .sql scripts rather than running one at a time?
 
> ok, it looks like the problem might have been caused when someone truncated the log file because of storage space issues a few months back.

Still strange...


> Is there a way that I can batch run the 300 .sql scripts rather than running one at a time?

This is trivial from command prompt, with FOR statement or shell extension a la 4NT. Or you can try something like this:

Open command prompt, go to directory with 300 .SQL scripts. Type:

dir *.sql /b > blah.bat

Open blah.bat with any editor capable of "column mode" selection (a la Textpad, UltraEdit, even VS/InterDev). At the end of every line insert osql stuff:

osql -Sserver -Uuser -Ppassword -ddbname <

The rest of line should have script name and nothing else.

Run blah.bat.

Maybe there are some other (GUI) ways to do that, dunno.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
> At the end of every line insert osql stuff:

Correction: not end, beginning... obviously [smile]

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top