Hardik Patel

Hardik Patel

  • NA
  • 378
  • 468.2k

how to store value in variable from store procedure?

Jul 16 2013 4:45 AM
store procedure :


Set @total = ( select SUM(w.FinalAmount) from ChequeDetailsWO  cdw
inner join WO w on cdw.WOCode = w.WOCode
inner join SupplierMaster sm on cdw.SupplierCode = sm.SupplierCode
inner join YearMaster ym on cdw.FinancialYear = ym.YearId
where AdvancePayment = 'true'
and cdw.SupplierCode = coalesce(@suppliercode,cdw.SupplierCode)
and cdw.WOCode = coalesce(@wocode,cdw.WOCode)  
and cdw.FinancialYear = coalesce(@year,cdw.FinancialYear)
and w.WODate between coalesce(@datefrom,w.WODate) and coalesce(@dateto,w.WODate)  )



 select @total as 'tt', ym.Year 'Financial Year', sm.SupplierName,w.WONumber,Convert(nvarchar,w.WODate,106)'WODate',w.FinalAmount,cdw.ChequeNumber,Convert(nvarchar,cdw.ChequeDate,106)'ChequeDate',cdw.TDS from ChequeDetailsWO  cdw
inner join WO w on cdw.WOCode = w.WOCode
inner join SupplierMaster sm on cdw.SupplierCode = sm.SupplierCode
inner join YearMaster ym on cdw.FinancialYear = ym.YearId
where AdvancePayment = 'true'
and cdw.SupplierCode = coalesce(@suppliercode,cdw.SupplierCode)
and cdw.WOCode = coalesce(@wocode,cdw.WOCode)  
and cdw.FinancialYear = coalesce(@year,cdw.FinancialYear)
and w.WODate between coalesce(@datefrom,w.WODate) and coalesce(@dateto,w.WODate)
order by sm.SupplierName



i want to store @total on my page in variable "t"

 t = ds.Tables[0].Rows[0]["@total"].ToString();

            Label3.Text = t.ToString();

Answers (3)