March 10, 2017 at 5:58 am
Hello All Experts,
i am not getting the correct result or may be i am not able to understand it.
i have written below query , can anyone figure it out what could be the wrong in this
DECLARE @v1 sql_variant;
SET @v1 = '1';
declare @temp table (ID int )
select 1 from @temp
Where 1=(case when SQL_VARIANT_PROPERTY(@v1, 'BaseType') in ('varchar','nvarchar','char') then 1 else 0 end)
the above query i am trying , ones it gets succesfull i will merge this into my main query.
March 10, 2017 at 6:31 am
If you don't tell us what you are expecting, how do you expect us to help?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
March 10, 2017 at 6:46 am
DECLARE @v1 sql_variant;
SET @v1 = '1';
declare @temp table (ID int )
select (case when SQL_VARIANT_PROPERTY(@v1, 'BaseType') in ('varchar','nvarchar','char') then 1 else 0 end)
Try this code.
In your example the table is empty.
Maybe this does illustrate what you are doing wrong:DECLARE @v1 sql_variant;
SET @v1 = '1';
declare @temp table (ID int )
insert into @temp values(1)
insert into @temp values(2)
insert into @temp values(3)
select *, 1 from @temp
Where 1=(case when SQL_VARIANT_PROPERTY(@v1, 'BaseType') in ('varchar','nvarchar','char') then 1 else 0 end)
Ben
March 12, 2017 at 11:18 pm
ben.brugman - Friday, March 10, 2017 6:46 AMDECLARE @v1 sql_variant;
SET @v1 = '1';
declare @temp table (ID int )
select (case when SQL_VARIANT_PROPERTY(@v1, 'BaseType') in ('varchar','nvarchar','char') then 1 else 0 end)
Try this code.In your example the table is empty.
Maybe this does illustrate what you are doing wrong:
DECLARE @v1 sql_variant;
SET @v1 = '1';
declare @temp table (ID int )
insert into @temp values(1)
insert into @temp values(2)
insert into @temp values(3)
select *, 1 from @temp
Where 1=(case when SQL_VARIANT_PROPERTY(@v1, 'BaseType') in ('varchar','nvarchar','char') then 1 else 0 end)Ben
i have tried with the above except for i have not use sql_variant as datatype.
i have used , int, varchar, char, etc.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply