Untitled

 avatar
unknown
plain_text
a year ago
451 B
4
Indexable
-- Step 1: Add a new column with NVARCHAR data type
ALTER TABLE Products
ADD Category_new NVARCHAR(50) NULL;

-- Step 2: Update the new column with values from the existing column
UPDATE Products
SET Category_new = CAST(Category AS NVARCHAR(50));

-- Step 3: Drop the existing column
ALTER TABLE Products
DROP COLUMN Category;

-- Step 4: Rename the new column to the original column name
EXEC sp_rename 'Products.Category_new', 'Category', 'COLUMN';
Editor is loading...
Leave a Comment