Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
451 B
1
Indexable
Never
-- 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';
Leave a Comment