I have a SQL server database design problem.
I have an existing database table with hundreds of records in there. One of the columns is of type NVARCHAR but it should be an integer with all the data in a lookup table.
Is there any clever way in SQL Server to get the data out of the column and into a new lookup table, change the datatype of the column and update the values with the correct ID from the new lookup table??
Thanks in advance.
I’m using SQL Server 2008
No, you have to do it as 3 steps:
nvarcharcolumn now contains appropriate ID values from the lookup tableintThankfully,
intvalues should always be able to fit in annvarchar, unless it’s an especially small one (in which case you’ll have to expand it first).