Let's say I have this table :

```
DECLARE @Var INT  
SET @Var = (select day from source)
SELECT * FRom TMP
INTO #TARGET
Where tmp.date >= dateadd(day,datediff(day,0,GETDATE()),0) - @Var
          tmp.date  <= dateadd(day,datediff(day,0,GETDATE()),0)

```

The query get the result if `@val != 0` but don't work when `@val=0`