• shah_khan_1289 (7/23/2014)


    this is my first sp

    create proc createSp1(@acc varchar(20),@columnname varchar(25))

    as

    declare @value flaot;

    set @query='select top 1 @value='+@columnname+' distict where DISTRICT='+@District;

    -- select @query;

    EXEC sp_executesql @query,N'@value nvarchar OUTPUT',@value OUTPUT;

    select @value +100;

    end

    //---------------

    this is my second sp

    create proc sp2(@data varchar(20))

    set @data='select distinct CURRENT_YR_RATE,exec sp1(acc,j.columname) as estimatedrate from dist j

    where DISTRICT IN ('''+@data+''')';

    EXEC sp_executesql @data

    end

    this is my DML

    It may just be me but are you sure that the first stored procedure actually works?? I don't even see a FROM clause in the dynamic SQL, so where is it pulling data? Also, not too sure about your call to sp_executesql as it doesn't fully resemble anything I have written.