Lets suppose You have executed the given query in SQL SERVER 2014.
Create TABLE Testable(Id INT PRIMARY KEY, Name Varchar(10), Status INT)
INSERT INTO Testable VALUES (1,'AMNIT',0)
INSERT INTO Testable VALUES (2,'Anny',1)
SELECT ID,(CASE WHEN Status = 1 THEN 'Inactive' ELSE Status END) as 'Status' FROM Testable
But getting the below error.
Msg 245, Level 16, State 1, Line 4
Conversion failed when converting the varchar value 'Inactive' to data type int.
This is very common error. You are trying to convert a varchar value to an int data type but the varchar value cannot be converted to Int data type.
In above SELECT Statement, “Status” column is integer but You are using value “Inactive” which is string.
Use Cast function to convert Integer value as Varchar.
SELECT ID,(CASE WHEN Status = 1 THEN 'Inactive' ELSE cast(Status as varchar(20)) END) as Status FROM Testable
If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.
Clients will find it using our advanced search filter and will contact you directly.
No any charge for the product lsiting.