set null操作

declare @salesstaff varchar(50)
set @salesstaff = null
SELECT @SalesStaff = SalesStaff FROM bdCustomerAllocate WHERE Departmentid = 4 AND CustomerID = -111
if ( @salesstaff  is   null )
begin
    print 'null'
end
else
begin
    print 'sdf'
end

若数据库中没有此记录,则不会给 @SalesStaff赋值,它会保留原值,故最好在赋值前将其设为NULL