Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to script sp in ms sql server 2008
Posted
Comments
Project CSE 25-Feb-15 2:04am    
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[AddPreviousSalaryData]
as
begin

insert into MonthlyPSOthersHistory select Right('0000000'+IdNumber,8) as MpoPIN,YEAR(Paid_date) as MpoYear, MONTH(Paid_date) as MpoMonth
,Paid_date as MpoGenDate,IsNull(Basic,0) as MpoBasicAmount, 0 as MpoOtherAmount,'' as MpoOtherAmountName,0 as MpoConsolidatedYN
,0 as MpoCashYN,0.00 as MpoOtherAdjAmount,'' as MpoOtherAdjNotes,0 as MpoUPLDeduction,0 as MpoTranDeduction, IsNull(InTax,0) as MpoIncomeTax
,IsNull(PF,0) as MpoPFAmount, IsNull(HBL,0) +IsNull(CL,0)+IsNull(CCS,0)+IsNull(CS,0) as MpoLoanReaAmount, IsNull(Others,0) as MpoRCDeductAmt, 0 as MpoSecurityAmt, 1 as MpoAutoGenYN,null as MpoAccCode,
IsNull(Entry_Time,GETDATE()) as SetDate,IsNull(Entry_User,'') as UserName1,0 as VerifiedYN,'' as UserName2,'P' as MpoAccPostingStatus from Salary_hstry

insert into MonthlyPSDetailsHistory
select Right('0000000'+IdNumber,8) as MphPIN,YEAR(Paid_date) as MphYear,MONTH(Paid_date) as MphMonth, '001' as MphSbkID,IsNull(Basic,0) as MphAmount,'P' as MphAccPostingStatus from Salary_hstry
union all
select Right('0000000'+IdNumber,8) as MphPIN,YEAR(Paid_date) as MphYear,MONTH(Paid_date) as MphMonth, '401' as MphSbkID,IsNull(HRent,0) as MphAmount,'P' as MphAccPostingStatus from Salary_hstry
union all
select Right('0000000'+IdNumber,8) as MphPIN,YEAR(Paid_date) as MphYear,MONTH(Paid_date) as MphMonth, '009' as MphSbkID,IsNull(HMnt,0) as MphAmount,'P' as MphAccPostingStatus from Salary_hstry
union all
select Right('0000000'+IdNumber,8) as MphPIN,YEAR(Paid_date) as MphYear,MONTH(Paid_date) as MphMonth, '008' as MphSbkID,IsNull(Utility,0) as MphAmount,'P' as MphAccPostingStatus from Salary_hstry
union all
select Right('0000000'+IdNumber,8) as MphPIN,YEAR(Paid_date) as MphYear,MONTH(Paid_date) as MphMonth, '006' as MphSbkID,IsNull(Med,0) as MphAmount,'P' as MphAccPostingStatus from Salary_hstry
union all
select Right('0000000'+IdNumber,8) as MphPIN,YEAR(Paid_date) as MphYear,MONTH(Paid_date) as MphMonth, '010' as MphSbkID,IsNull(LFA,0) as MphAmount,'P' as MphAccPostingStatus from Salary_hstry
union all
select Right('00000000'+IdNumber,8) as MphPIN,YEAR(Paid_date) as MphYear,MONTH(Paid_date) as MphMonth, '005' as MphSbkID,IsNull(Ent,0) as MphAmount,'P' as MphAccPostingStatus from Salary_hstry
union all
select Right('0000000'+IdNumber,8) as MphPIN,YEAR(Paid_date) as MphYear,MONTH(Paid_date) as MphMonth, '007' as MphSbkID,IsNull(Conv,0) as MphAmount,'P' as MphAccPostingStatus from Salary_hstry
--union all
--select Right('0000000'+IdNumber,8) as MphPIN,YEAR(Paid_date) as MphYear,MONTH(Paid_date) as MphMonth, '005' as MphSbkID,Ent as MphAmount,'P' as MphAccPostingStatus from Salary_hstry

End

begin transaction
exec AddPreviousSalaryData
rollback transaction
_Asif_ 25-Feb-15 2:06am    
We can't read your mind, your hard disk and your screen. You need to explain your problem well, please improve your question by adding more details
Dinesh92d 25-Feb-15 2:11am    
Your Qus is how to run the script? ist
Thanks7872 25-Feb-15 2:23am    
- Open sp in SSMS and press ctrl + s.
- Another option is, right click sp-Script procedure as-select option you want
Project CSE 15-Mar-15 3:27am    
---------------------------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX----------------------------------

1 solution

This script might help..
How to script all stored procedures in a database[^]
Generate Scripts for SQL Server Objects
[^]
Alternatively you can also use SQL wizard to create SP Scripts\Use the scripting wizard Right-click the db –> tasks –> Generate scripts –> go through the wizard.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900