sql server - select query, compare null records -



sql server - select query, compare null records -

i'm writing sql server query:

select * vwapplicationlist status='unassigned' , bbl '%' + @bbl + '%' , unitorappartmentnumber '%'+@appartment+'%' , residencetypedescription '%'+@residencetypedescription+'%' , sn1 '%'+@sn1+'%' , sn2 '%'+@sn2+'%'

the problem field "sn2" null in several records. how can compare them?

if want positive result on comparison:

... , coalesce(sn2, @sn2) '%' + @sn2 + '%'

if want negative result (assuming @sn2 not empty string):

... , coalesce(sn2, '') '%' + @sn2 + '%'

sql-server select null

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -