Hi,
Try this:
SE [NPA_TEST]
GO
/****** Object: StoredProcedure [dbo].[ON_INVOICE] Script Date: 03/13/2014 11:06:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ON_INVOICE]
BEGIN
--IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tbl]') AND type in (N'U'))
--DROP TABLE [dbo].[tbl]
SELECT T2.[DocNum],
T2.[DocType], T2.[CardName] as "supplier Name",
--T2.JrnlMemo as "description" ,
T2.DocDate ,t2.CardCode as "code",t2.DocCurr as "currency"
,T2.[Address], T2.DocTotal,t2.DocTotalFC,
T3.[WtAppld] as "applied with-holding tax",T2.u_CA as "Account Chargeable", t2.Comments,
t4.U_NAME as " Name ",t3.SumApplied ,t3.InvType ,t2.NoDocSum ,t3.WtAppldFC
--ROW_NUMBER ()over(PARTITION by t2.docnum order by t2.cardname) as "Test"
--,t5.NumAtCard as "invoice number",
--into tbl
--,t5.DocEntry,t5.OwnerID
FROM OVPM T2
INNER JOIN VPM2 T3 ON T2.DocEntry = T3.DocNum
inner join OUSR t4 on t4.USERID = t2.UserSign
--inner join OPCH t5 on t5.CardCode =t2.CardCode and t5.DocEntry=T3.Docentry
--inner join OWDD t5 on t5.DocEntry =t2.DocEntry and t5.OwnerID =t4.USERID
-- inner join WDD1 t6 on t5.WddCode = t6.WddCode and t6.UserID =t4.USERID
WHERE T2.[DocType] = 'S'
--group by T2.[DocNum],
-- T2.[DocType], T2.[CardName], T2.JrnlMemo ,T2.DocDate ,t2.CardCode ,t2.DocCurr
--,T2.[Address], T2.DocTotal,t2.DocTotalFC,
-- T3.[WtAppld] ,
-- T2.u_CA , t2.Comments,
--t4.U_NAME ,t3.SumApplied
--and t5.ObjType = 140
--t5.NumAtCard ,
--delete from tbl
--where test > 1
--select * from tbl
END
Thanks & Regards,
Nagarajan