USE [Agri]
GO
/****** Object: StoredProcedure [dbo].[in_dm] Script Date: 09/14/2013 11:16:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create PROCEDURE [dbo].[idm]
(@Product varchar(15),@Date DateTime ,@BillNo varchar(30) ,
@CustomerName varchar(50),@Address varchar(50) ,
@BrandName varchar(50) ,@Quantity varchar(20),
@ProductPrice varchar(20) , @Requiredno varchar(50),
@Price varchar(50), @Extra varchar(20) ,
@Vat varchar(50),@TotalAmount varchar(50),
@CorrectPrice varchar(50),@type varchar(10)
)
AS
BEGIN
insert into sampl (ProductName,Date,BillNo,CustomerName,Address,BrandName,
Quantity,ProductPrice,Requiredno,Price,Vat,TotalAmount,type)
values(@Product,@Date,@BillNo ,@CustomerName ,@Address ,@BrandName ,
@Quantity ,@ProductPrice ,@Requiredno ,@Price ,@Vat ,@TotalAmount,@type);
insert into samle (ProductName,Date,BillNo,CustomerName,Address,BrandName,
Quantity,ProductPrice,Requiredno,Price,Extra,Vat,CorrectPrice,type) values
(@Product ,@Date,@BillNo ,@CustomerName ,@Address ,@BrandName ,@Quantity ,
@ProductPrice ,@Requiredno ,@Price ,@Extra ,
@Vat,@CorrectPrice,@type );
END
if @type='s'
begin
update pr set purno=purno-Requiredno where BrandName=@BrandName
end
===================================================================
need to update the table pr reduce the requiredno from purno (but requiredno is not inn the table pr) the required no is in the table sampl and samle .

venkata kumarPosted Sep 21, 2013, 8:00 AM
try the fallowing
declare @purno int
set @purno=(select top 1 purno from pr where brandname=@brandname)
declare @Reqno int
set @reqno=(select top 1 requiredno from samp where brandname=@brandname)
Jignesh TrivediPosted Sep 20, 2013, 3:37 AM
I think, problem with these two line
declare @purno int
set @purno=(select purno from samp where brandname=@brandname)
declare @Reqno int
set @reqno=(select requiredno from samp where brandname=@brandname)
Instead of this try
declare @purno int
Select @purno = purno from samp where brandname=@brandname
declare @Reqno int
select @Reqno =requiredno from samp where brandname=@brandname
hope this will help you.
selvi subramanianPosted Sep 20, 2013, 3:14 AM
venkata kumarPosted Sep 16, 2013, 6:12 AM
try this
declare @purno int
set @purno=(select purno from pr where brandname=@brandname)
declare @Reqno int
set @reqno=(select requiredno from samp where brandname=@brandname)
update pr set purno=@purno-@Reqno where BrandName=@BrandName
selvi subramanianPosted Sep 16, 2013, 5:47 AM
next table
pr table
procedure is above . need to reduce from the pr table if inserted in sampl,samle.
in pr table purno is 100. in sampl,samle the required no is 50. i need in or table (100-50=50)
Jignesh TrivediPosted Sep 16, 2013, 2:57 AM
hi,
In SQL,
null + 50 = null
i think you have same problem...
try
update pr set purno= isnull(purno,0)-isnull(Requiredno,0) where BrandName=@BrandName
hope this will help you.
venkata kumarPosted Sep 16, 2013, 1:05 AM
give mee proper details
selvi subramanianPosted Sep 14, 2013, 7:04 AM
venkata kumarPosted Sep 14, 2013, 4:50 AM
try fallowing
declare @purno int
set @purno=(select purno from samp where brandname=@brandname)
declare @Reqno int
set @reqno=(select requiredno from samp where brandname=@brandname)
update pr set purno=@purno-@Reqno where BrandName=@BrandName