Ok I think so what do you need
First option:
CREATE TABLE Products(
identifier int identity(1,1),
name varchar(50)
UNIQUE (name)
)
INSERT INTO Products(name) VALUES('Product 1')
INSERT INTO Products(name) VALUES('Condiments')
INSERT INTO Products(name) VALUES('Product 3')
INSERT INTO Products(name) VALUES('Dairy Products')
SELECT * FROM Products
UPDATE Products
SET name = 'Condiments'
WHERE identifier = 4
INSERT INTO Products(name) VALUES('Condiments')
DROP TABLE Products
Second Option:
CREATE TABLE Products(
identifier INT IDENTITY(1,1),
name VARCHAR(50)
)
DECLARE @OLDname AS VARCHAR (50),
@NEWname AS VARCHAR (50)
SET @OLDname = 'Dairy Products'
SET @NEWname = 'Condiments'
INSERT INTO Products(name) VALUES('Product 1')
INSERT INTO Products(name) VALUES('Condiments')
INSERT INTO Products(name) VALUES('Product 3')
INSERT INTO Products(name) VALUES('Dairy Products')
IF EXISTS(SELECT * FROM Products WHERE name = @NEWname)
BEGIN
SELECT @NEWname + ' EXIST IN THE TABLE'
END
ELSE
BEGIN
SELECT 'YOU CAN MAKE AN UPDATE FROM ' + @OLDname + ' TO ' + @NEWname
END
DROP TABLE Products