June 21, 2008 at 6:58 am
Hi friends,
i need to change the data type from numeric to uniqueidentifier.
i have a tables domain, location and visit.
table - domain (domain_id, name,creator,date)
table - location (location_id, location_name, domain_id, date)
table - visit(visit_id, domain_id,location_id)
there are foriegnkey relations on these tables. i need to change the data type for the ids(domain_id,location_id and visit_id) from the numceric to uniqueidentifier.
how to change the data type for these columns.
i can;t change it manually because i am having totally 150 tables and having the relations most of the tables.
is there any way using the alter table statement to change the data type?
thanks in advance.
June 21, 2008 at 7:34 am
Try to figure out the Order of the tables vs constraints.
Drop the constraints
Change the Datatype and re-create the constraints.
Or Next Option will be using
ALTER TABLE
ALTER COLUMN [column_name] [new_data_type]
Maninder
www.dbanation.com
June 21, 2008 at 9:58 am
I'd do the first listed above, but script out the tables and dependencies from SSMS, modify the scripts, and then run them to alter the tables.
If you alter a table in SSMS, you can get the script before you commit the change by clicking the script toolbar button at the top.
June 22, 2008 at 4:17 am
When table having the primary key and constraints we cant use the alter table
alter column [column] statement.
i have 150 table. when i delete the relation and can create the relations after changing the data type. but it will take tiem.
June 22, 2008 at 10:24 am
This is a duplicate topic. Please do not cross-post.
Please direct all future replies to this topic:http://www.sqlservercentral.com/Forums/FindPost521163.aspx
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply