SQLTeam.com | Weblogs | Forums

How to omit

Hi guys,

I would like to omit those two exact guids from the result, is this where clause OK?

Where referenceId NOT LIKE '00000000%'

00000000-0000-0000-0000-000000000001
00000000-0000-0000-0000-000000000000

hi

see this for idea

What version of sql server are you on and what datatype is that column?

uniqueidenfier, sql server 2016.

Are these values being passed to a stored procedure? If so, how?

use sqlteam
go

create table #cenk(referenceId uniqueidentifier default(newid()) )

;with src
as
(

	select '00000000-0000-0000-0000-000000000001' as referenceId
	union
	select '00000000-0000-0000-0000-000000000000' 
)

insert into #cenk(referenceId)
select top 10 NEWID() as referenceId
 from sys.columns a
union
select referenceId
 from src


 select *
   from #cenk
   where referenceId not in(
   '00000000-0000-0000-0000-000000000001', 
'00000000-0000-0000-0000-000000000000' 
   )


 select *
   from #cenk
   where referenceId in (
   '00000000-0000-0000-0000-000000000001', 
'00000000-0000-0000-0000-000000000000' 
   )

   drop table #cenk

Yes, that will exclude them, but it would exclude a lot more.

You could restrict the LIKE more, like so:

Where referenceId NOT LIKE '00000000-0000-0000-0000-00000000000[01]%'

3 Likes