Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Renaming tables

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2006-04-28 : 09:28:56
Hi i want to rename 6 tables, these tables are link to views, and other tables, the reason am doing this is that i've a Error msg on "Cannot resolve collation conflict for equal to operation." So my collation are different, i've to re create the tables with the same collation and then populate them again.

If i rename the tables to old and and rename the table i've name new (which have the correct collation )to what the old tables were initall call with this be ok ?

Example

EXEC sp_rename 'rca', 'rcaold'
EXEC sp_rename 'rcanew', 'rca'

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-04-28 : 11:56:56
If your objective is to change the collation I believe you can use ALTER TABLE, see Books Online.

quote:

ALTER TABLE table
{ [ ALTER COLUMN column_name
{ new_data_type [ ( precision [ , scale ] ) ]
[ COLLATE < collation_name > ]
[ NULL | NOT NULL ]
| {ADD | DROP } ROWGUIDCOL }




Be One with the Optimizer
TG
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-04-28 : 13:35:08
I've only ever done:

CREATE TABLE MyTemp ...

INSERT INTO MyTemp ... SELECT ... FROM MyRealTable

DROP TABLE MyRealTable

EXEC sp_rename 'MyTemp', 'MyRealTable'

and existing Sprocs and VIEWs etc. see to work OK. However, triggers on MyRealTable are dropped along with the table, and Foreign Keys, and Indexes ...

The easiest way I think is to use the Table Design tool in Query Analyser. make all the changes, then use the "Generate Change Script" to get a SQL Script and abandon the changes in Table Design tool. That will generate the complete "Drop constraints, Make temporary table, INSERT INTO ... SELECT * FROM ..., Drop original, Rename tables, reinstate PK, Indexes, FKs, Triggers etc. etc.

Kristen
Go to Top of Page
   

- Advertisement -