This is intermediate level SQL scripting article for DB Administrator, Programmer, IT Specialist
Our and Microsoft Business Solutions goal here is to educate database administrator, programmer, software developer to enable them support Microsoft Great Plains for their companies. In our opinion self support is the goal of Microsoft to facilitate implementation of its products: Great Plains, Navision, Solomon, Microsoft CRM. You can do it for your company, appealing to Microsoft Business Solutions Techknowledge database. This will allow you to avoid expensive consultant visits onsite. You only need the help from professional when you plan on complex customization, interface or integration, then you can appeal to somebody who specializes in these tasks and can do inexpensive nation-wide remote support for you.
Let's look at interest calculation techniques.
Imagine that you are financing institution and have multiple customers in two companies, where you need to predict interest. The following procedure will do the job:
CREATE PROCEDURE AST_Interest_Calculation
@Company1 varchar(10), --Great Plains SQL database ID
@Company2 varchar(10),
@Accountfrom varchar(60),
@Accountto varchar(60),
@Datefrom datetime,
@Dateto datetime--,
as
declare @char39 char --for single quote mark
declare @SDatefrom as varchar(50)
declare @SDateto as varchar(50)
select @SDatefrom = cast(@Datefrom as varchar(50))
select @SDateto = cast(@Dateto as varchar(50))
select @char39=char(39)
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AST_INTEREST_TABLE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[AST_INTEREST_TABLE] (
[YEAR] [int] NULL ,
[MONTH] [int] NULL ,
[COMPANYID] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[ACTNUMST] [char] (129) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[BEGINDATE] [varchar] (19) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[ENDDATE] [varchar] (19) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[YEARDEGBALANCE] [numeric](19, 5) NULL ,
[BEGBALANCE] [numeric](38, 5) NULL ,
[ENDBALANCE] [numeric](38, 5) NULL ,
[INTERESTONBALANCE] [numeric](38, 6) NULL ,
[INTERESONTRANSACTIONS] [numeric](38, 8) NULL ,
[INTEREST] [numeric](38, 6) NULL ) ON [PRIMARY]
exec("
delete AST_INTEREST_TABLE where [YEAR] = year("+ @char39 + @Datefrom + @char39 +") and [MONTH]=month("+ @char39 + @Datefrom + @char39 +")
insert into AST_INTEREST_TABLE
select
year(X.BEGINDATE) as [YEAR],
month(X.BEGINDATE) as [MONTH],
X.COMPANYID,
X.ACTNUMST,
X.BEGINDATE as BEGINDATE,
X.ENDDATE as ENDDATE,
X.YEARBEGBALANCE as YEARDEGBALANCE,
X.YEARBEGBALANCE+X.BEGBALANCE as BEGBALANCE,
X.YEARBEGBALANCE+X.ENDBALANCE as ENDBALANCE,
X.INTERESTONBALANCE as INTERESTONBALANCE,
X.INTERESTONTRANSACTIONS as INTERESONTRANSACTIONS,
X.INTERESTONBALANCE+X.INTERESTONTRANSACTIONS as INTEREST
--into AST_INTEREST_TABLE
from
(
select
"+ @char39+ @Company1 + @char39+" as COMPANYID,
a.ACTNUMST,
"+ @char39 + @Datefrom + @char39 +" as BEGINDATE,
"+ @char39 + @Dateto + @char39 +" as ENDDATE,
case when
b.PERDBLNC is null then 0
else b.PERDBLNC
end as YEARBEGBALANCE,
sum
(
case
when (c.DEBITAMT-c.CRDTAMNT is not null and c.TRXDATE ="+ @char39 + @SDatefrom + @char39 +" and c.TRXDATE =year("+ @char39 + @Datefrom + @char39 +")
where
a.ACTNUMST>="+@char39+@Accountfrom+@char39 +"
and a.ACTNUMST="+ @char39 + @SDatefrom + @char39 +" and c.TRXDATE =year("+ @char39 + @Datefrom + @char39 +")
where
a.ACTNUMST>="+@char39+@Accountfrom+@char39 +"
and a.ACTNUMST
weekly home cleaning Bannockburn ...SOFTWARE PIRACY We regularly hear reports... Read More
Rapid Application Development (RAD) is a software development methodology. In... Read More
Microsoft Business Solutions Great Plains has many years of successful... Read More
While I was preparing some personal background information for a... Read More
TCO (Total Cost Ownership) is the buzzword in... Read More
Case study: A secretary using Corel WordPerfect 7 is often... Read More
Are you a database professional? Do you work with a... Read More
This article is the first of a series of articles... Read More
Microsoft Great Plains - Microsoft Business Solutions accounting and ERP... Read More
When Windows fails to boot it is normally caused by... Read More
The world of small business accounting software can be a... Read More
People often ask me: What image file formats will Photoshop... Read More
Does Microsoft care for WebmastersIt's always been a problem with... Read More
With the advent of 'Service Pack 2' for Windows XP... Read More
Microsoft Business Solutions Great Plains, Navision, Axapta, Solomon and CRM... Read More
MicroWorld Technologies, Inc. the leading solutions provider in the area... Read More
Microsoft Business Solutions main middle market ERP application - Microsoft... Read More
Most people don't use Photoshop to its fullest capabilities. Here... Read More
The java programming language is becoming more and more popular... Read More
Microsoft Great Plains is now standard mid-market ERP application, serving... Read More
How do you run a program on a remote server... Read More
Microsoft bought Navision, Denmark based software development company, along with... Read More
Microsoft Business Solutions products: Great Plains, MS CRM, Navision, Axapta,... Read More
This tutorial covers OLAP solutions used by Data warehouses and... Read More
In this short FAQ style article we would like to... Read More
eco-friendly cleaning service Bannockburn ...In this short FAQ style article we would like to... Read More
If you feel intimidated when someone tries to teach you... Read More
Lotus Domino/Notes ? Microsoft Great Plains tandem as ERP with... Read More
Are Spreadsheets Robbing your Enterprise of Competitive Advantage?'90% of "average"... Read More
Preventive Maintenance (PM) is defined as scheduled work done on... Read More
After almost two decades of existence, Quark has become the... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
Microsoft CRM ? Client Relationship Management package from Microsoft Business... Read More
When reading an article where some term is used often,... Read More
As you probably know, when Microsoft purchased Great Plains Software... Read More
Remember back in the days where screensavers were the coolest... Read More
The purpose of one of our projects was MS Exchange... Read More
When you think... Read More
MicroWorld Technologies, Inc. the leading solutions provider in the area... Read More
Not all of us have the luxury of working both... Read More
The Internet is reshaping every form of communications medium, and... Read More
Linux essentials:It's free for download but you have to pay... Read More
Sometimes your PC will start acting strange for no apparent... Read More
Microsoft has never released a service pack for Windows98 SE,... Read More
When you buy a computer, it most likely comes with... Read More
In the new era of internet marketing the problem of... Read More
Many Webmasters have never bothered to view their website's server... Read More
First we had the original Google search that evolved into... Read More
In the case when you represent mid-size or mid-size-to-large business,... Read More
The Windows registry is a huge database that ensures normal... Read More
Software |