May 19, 2015 at 8:18 am
Ok following scenario
create table dbo.ADAssets
(Computername nvarchar(max))
insert into dbo.ADAssets
values
('AIRLBEOF3565 CNF:4e926e06-6f62-4864-aebd-6311543d',
'AIRLBEOF3565')
So if execute the following
select Computername
from dbo.ADAssets
where Computername like
'AIRLBEOF3565%'
I get both records,but if I do this
select *
from dbo.ADAssets
where Computername in
(
'AIRLBEOF3565 CNF:4e926e06-6f62-4864-aebd-6311543d',
'AIRLBEOF3565'
)
I only get AIRLBEOF3565
So the big picture is that I need to compare 2 tables to find records that match & don't but that I get matches that shouldn't be & matches that aren't
May 19, 2015 at 9:06 am
Resender (5/19/2015)
Ok following scenario
create table dbo.ADAssets
(Computername nvarchar(max))
insert into dbo.ADAssets
values
('AIRLBEOF3565 CNF:4e926e06-6f62-4864-aebd-6311543d',
'AIRLBEOF3565')
So if execute the following
select Computername
from dbo.ADAssets
where Computername like
'AIRLBEOF3565%'
I get both records,but if I do this
select *
from dbo.ADAssets
where Computername in
(
'AIRLBEOF3565 CNF:4e926e06-6f62-4864-aebd-6311543d',
'AIRLBEOF3565'
)
I only get AIRLBEOF3565
So the big picture is that I need to compare 2 tables to find records that match & don't but that I get matches that shouldn't be & matches that aren't
First of all get rid of nvarchar(max).
May 19, 2015 at 9:19 am
Please will you check your INSERT statement? You're trying to insert two columns into a single-column table.
John
May 19, 2015 at 10:21 am
Yep, if you insert the data correctly, both queries work:
create table dbo.ADAssets
(Computername sysname)
insert into dbo.ADAssets
values
(N'AIRLBEOF3565 CNF:4e926e06-6f62-4864-aebd-6311543d'),
(N'AIRLBEOF3565');
select Computername
from dbo.ADAssets
where Computername like
'AIRLBEOF3565%';
select *
from dbo.ADAssets
where Computername in
(
'AIRLBEOF3565 CNF:4e926e06-6f62-4864-aebd-6311543d',
'AIRLBEOF3565'
);
May 20, 2015 at 2:52 am
OK,that indeed seems to work,I initially wanted to ask this question using multiple columns & then when I finished writing the post realised I overcomplicated my question,so I simplified the statements for the create table but forgot the insert.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply