I am writing code that needs to recognize if a column is empty or not in my database based on a specific ID. I am using Microsoft SQL Server Management Studio.
I've tried:
select count(*) as valid from table where id =7PB03150SW
But receive the error:
Conversion failed when converting the varchar value to data type int.
I also tried:
select cast(( select count(*) from table where id = 7PB03150SW)as VarChar(120))
But receive the error:
Conversion failed when converting the varchar value to data type int.
I want the code to output a single result, the number of times the specific ID appears in the table. The output needs to be able to be read by a c# file.