Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conversion from 'uniqueidentifier' to 'int' is not supported on the connected database server

Tags:

I'm about to migrate my database from using old membership to the one included in mvc4, which uses int instead of guid.

When changing the type I get following error:

Conversion from int to uniqueidentifier is not supported on the connected database server.

How can I change UserId to int via SQL Server Management Studio?

like image 589
I'm busy coding Avatar asked Feb 25 '13 14:02

I'm busy coding


2 Answers

First Change Data Type to any other supported Type like varbinary or anything. then you can convert from that to what you want.

like image 163
Muhamed Shafeeq Avatar answered Oct 30 '22 12:10

Muhamed Shafeeq


You have to add a new column ( ALTER TABLE ADD [NewId] INTEGER ) then run the following to populate the new id column :

WITH Cte AS (     SELECT *     , ROW_NUMBER() OVER(ORDER BY [Your GUID Column Here] DESC) AS RowNumber     FROM YourTable ) UPDATE Cte SET [NewId]= RowNumber GO 

There you have a new ID column that you can use a clustered primary key

like image 27
jazzytomato Avatar answered Oct 30 '22 11:10

jazzytomato