This is my code,could you please help 

```
declare @database_id varchar(50);
declare @name varchar(50);

declare Countofprovider cursor for
select database_id ,name
from sys.databases
where name like 'CPM_%stg'
group by name , database_id order by database_id

open Countofprovider

fetch next from Countofprovider
into @database_id, @name

while @@FETCH_STATUS = 0
begin
    --print 'ID : '+ @database_id+' , Name : '+ @name+ ''
    Declare @SQL nvarchar(MAX)

    -- declare @countprov varchar(50);
    SET @sql= '
      declare @countprov int

      select @countprov=count(*) from '+@name+'.dbo.Patients
      where birthdate is null or birthdate = '' or year(birthdate) = 1900

      insert into dbo.countofpaitnets(databse_id,name,countofpatients)
      values('''+@database_id+''','''+@name+''',@countprov)
    '

    exec (@SQL)

    --select count(*) from [CPM_CHE_WAVE3_STG].dbo.patinents where birthdate is null
    --insert into dbo.sampledbkarthi values ('+@database_id+' , '+@name+','+@countprov+')

    fetch next from Countofprovider
    into @database_id, @name, @countprov
end

CLOSE Countofprovider;
DEALLOCATE Countofprovider;

```

When I'm trying to execute it, I'm getting this error:

> 
> Must declare the scalar variable “@countprov” error
> 
> 
>