declare @v1 int
set @v1 = 10000
declare @query VARCHAR(5000)
SET @query = 'SELECT * FROM OPENQUERY (FirebirdDB, ''select KUNDEN.KUNDENNR FROM KUNDEN WHERE ' + isnull(cast(@v1 AS VARCHAR(20)),'NULL') + ' is null or t1.KUNDENNR = ' + cast(isnull(@v1,0) AS VARCHAR(20)) + ''')'
select @query
--SELECT * FROM OPENQUERY (FirebirdDB, 'select KUNDEN.KUNDENNR FROM KUNDEN WHERE 10000 is null or t1.KUNDENNR = 10000')
EXEC (@query)