Friday, January 24, 2014

sql_variant check varchar and nvarchar for stored procedure

if you have sql_variant field type and you search for any value in column you will get nothing in your query so you should convert the column and the check value to varchar first or nvarchar to get your search

example

begin
declare @x varchar(10) = 10
SELECT ProfileID FROM Profile WHERE
CONVERT(nvarchar(100),  MR_PATIENT_IF, 126) LIKE @x + '%';
end

No comments:

Post a Comment