Question

I'm making changes to a Sql Server (2008) database to change an existing column type from a UUID to a varchar(128) - the column, we'll call it reference was originally used to save an ID of a reference project that provided more information about the data in the row, but now the business requirements have changed and we're just going to allow free-form text instead. There were no foreign keys setup against the column, so there won't be any breaking relationships.

My biggest concern at the moment is one of backwards compatibility with existing stored procedures. Unfortunately, the database is very big and very old, and contains hundreds of stored procs littered throughout the design. I'm very nervous about making a change which could potentially break existing stored procs.

I know this is a loaded question, but in general, can UUID columns be converted into varchar columns without deleterious effects? It seems like any existing stored proc which inserted into or queried on the UUID column would still work, given that UUIDs can be represented as strings.

Was it helpful?

Solution

I've tried performed the below steps and I didn't see any issues, so i think you can go ahead and change the column datatype:

  1. Created the table with the column type as unique identifier.
  2. Created the stored procedure to insert a value into that table through NewID() function.
  3. Execute the stored procedure, and data was inserted without any issue.
  4. Now, I changed the column type to varchar and again executed the stored procedure.
  5. Procedure ran fine without any issue, and data was inserted.

So, the answer is Yes, you can change the column data type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top