Re: Altering columns...getting complicated...
- From: "Andrew D. Newbould" <newsgroups@xxxxxxxxxxxxxxxxx>
- Date: Wed, 18 May 2005 17:57:24 +0100
In message <OU#WxZ8WFHA.2420@xxxxxxxxxxxxxxxxxxxx>, YYZ <none@xxxxxxxx> writes
I have a need to write many scripts to alter a LOT the underlying database structure of our database in the field. We have many fields out there with a type of float, and I've been told to change those to numeric(19,5) -- easy enough. Unless there is a constraint, in which case I have to drop the constraint, alter the field, add the constraint back in. Easy enough again, once you know what you are doing.
Now, they tell me to change all the nvarchar(XX) fields to varchar(XX) -- easy enough again, unless they have a default -- use the same scheme as above, and it all works. UNLESS they are part of a primary key. Uh oh -- now I hit something I don't know how to solve...
What I'm thinking is that I should dump all of the indexes and primary keys and defaults out of all tables, and then just rebuild them all from scratch. However, this database was "created" by using the Access upsizing wizard, so I don't know all the primary key names, constraint names, etc.
Can anyone point me in the right direction to dump all indexes and defaults on every column in a database? I can re-create them pretty easily...
Any advice would be appreciated, or even an alternate method to do what I need to do.
Use a CURSOR to enumerate the SYSINDEXES system table in your database to find all the indexes on it. Alternatively, if you tied this up with the INFORMATION_SCHEMA.TABLES you can list the indexes on a table by table basis.
-- Andrew D. Newbould E-Mail: newsgroups@xxxxxxxxxxxxxxxxx
ZAD Software Systems Web : www.zadsoft.com .
- References:
- Prev by Date: Altering columns...getting complicated...
- Next by Date: Re: Install MSDE on Windows 2003 Small Business Server?
- Previous by thread: Altering columns...getting complicated...
- Index(es):
Relevant Pages
|