--Script for pulling between 9999.00 and 50000.00 from Cash account.
SELECT GL105.ACTNUMBR_2, GL105.ACTNUMBR_3, GL105.ACTNUMBR_4,
GL105.ACTINDX, GLGL2.JRNENTRY, GL2.SOURCDOC, GL2.REFRENCE,
GL2.DSCRIPTN, GL2.TRXDATE, GL2.ACTINDX, GL2.SERIES, GL2.CRDTAMNT,
GL2.DOCDATE, GL2.ORMSTRNM
FROM GL20000 AS GL2 INNER JOIN
GL00105 AS GL105 ON GL2.ACTINDX = GL105.ACTINDX
WHERE (GL105.ACTNUMBR_2 = '010') AND (GL105.ACTNUMBR_3 = '1040')
AND (GL105.ACTNUMBR_4 = '000') AND (GL2.TRXDATE > '01/1/2008') AND
(GL2.CRDTAMNT < 50000.00 and GL2.CRDTAMNT > '9999.00')
--- Statement to pull in all credit amounts greater than $50,000.00
from cash account
SELECT GL105.ACTNUMST, GL105.ACTNUMBR_2, GL105.ACTNUMBR_3,
GL105.ACTNUMBR_4, GL105.ACTINDX, GL2.JRNENTRY, GL2.SOURCDOC,
GL2.REFRENCE, GL2.DSCRIPTN, GL2.TRXDATE, GL2.ACTINDX, GL2.SERIES,
GL2.CRDTAMNT, GL2.DOCDATE
FROM GL20000 AS GL2 INNER JOIN
GL00105 AS GL105 ON GL2.ACTINDX = GL105.ACTINDX
WHERE (GL105.ACTNUMBR_2 = '010') AND (GL105.ACTNUMBR_3 = '1040')
AND (GL105.ACTNUMBR_4 = '000') AND (GL2.TRXDATE > '01/1/2008') AND
(GL2.CRDTAMNT > '50000.00')
Steps below will help:
1. First define a cursor that loops all the records in “SY01500” table (GP
Databases).
DECLARE CurDatabases Cursor For Select INTERID From SY01500
……
While...
Fetch Next From CurDatabases Into @DatabaseName
2. Change the database used in loop and run its command:
DECLARE @strCommand Varchar(500)
@strCommand = ‘USE ‘ + @DatabaseName
EXEC (@strCommand)
Add your commands here that include the data export.
End While
This what currently came to my mind, please let me know if you need any more
clarifications.
Regards,
--
Mohammad R. Daoud
MCP, MCBMSP, MCTS, MCBMSS
Mob: +962 - 79 -999 65 85
Great Package For Business Solutions
dao...@greatpbs.com
http://www.greatpbs.com
http://mohdaoud.blogspot.com/
I posted this only 3 days ago. :-)
David Musgrave [MSFT]
Escalation Engineer - Microsoft Dynamics GP
Microsoft Dynamics Support - Asia Pacific
Microsoft Dynamics (formerly Microsoft Business Solutions)
http://www.microsoft.com/Dynamics
mailto:David.M...@online.microsoft.com
http://blogs.msdn.com/DevelopingForDynamicsGP
Any views contained within are my personal views and not necessarily Microsoft policy.
This posting is provided "AS IS" with no warranties, and confers no rights.
open c_company
fetch next from c_company into @companyID
while @@fetch_status = 0
begin
set @sqlstmt = 'use ' + @companyID
exec @sqlstmt
SELECT GL105.ACTNUMBR_2, GL105.ACTNUMBR_3, GL105.ACTNUMBR_4,
GL105.ACTINDX, GLGL2.JRNENTRY, GL2.SOURCDOC, GL2.REFRENCE,
GL2.DSCRIPTN, GL2.TRXDATE, GL2.ACTINDX, GL2.SERIES, GL2.CRDTAMNT,
GL2.DOCDATE, GL2.ORMSTRNM
FROM GL20000 AS GL2 INNER JOIN
GL00105 AS GL105 ON GL2.ACTINDX = GL105.ACTINDX
WHERE (GL105.ACTNUMBR_2 = '010') AND (GL105.ACTNUMBR_3 = '1040')
AND (GL105.ACTNUMBR_4 = '000') AND (GL2.TRXDATE > '01/1/2008') AND
(GL2.CRDTAMNT < 50000.00 and GL2.CRDTAMNT > '9999.00')
--- Statement to pull in all credit amounts greater than $50,000.00
from cash account
SELECT GL105.ACTNUMST, GL105.ACTNUMBR_2, GL105.ACTNUMBR_3,
GL105.ACTNUMBR_4, GL105.ACTINDX, GL2.JRNENTRY, GL2.SOURCDOC,
GL2.REFRENCE, GL2.DSCRIPTN, GL2.TRXDATE, GL2.ACTINDX, GL2.SERIES,
GL2.CRDTAMNT, GL2.DOCDATE
FROM GL20000 AS GL2 INNER JOIN
GL00105 AS GL105 ON GL2.ACTINDX = GL105.ACTINDX
WHERE (GL105.ACTNUMBR_2 = '010') AND (GL105.ACTNUMBR_3 = '1040')
AND (GL105.ACTNUMBR_4 = '000') AND (GL2.TRXDATE > '01/1/2008') AND
(GL2.CRDTAMNT > '50000.00')
fetch next from c_company into @companyID
close c_company
deallocate c_company
Best regards,
--
MG.-
Mariano Gomez, MIS, MCP, PMP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com
The Dynamics GP Blogster at http://dynamicsgpblogster.blogspot.com
You are all sweethearts...
Thank you so much ..... I learn more from this site, David, Leslie and
Mariano then I have learned from all my other resources
There is an unsupported Microsoft SQL System Stored Procedure called
SP_MSForEachDB. You can run your code through that.
SP_MSForEachDB 'SELECT GL105.ACTNUMBR_2, GL105.ACTNUMBR_3,
GL105.ACTNUMBR_4,
GL105.ACTINDX, GLGL2.JRNENTRY, GL2.SOURCDOC, GL2.REFRENCE,
GL2.DSCRIPTN, GL2.TRXDATE, GL2.ACTINDX, GL2.SERIES, GL2.CRDTAMNT,
GL2.DOCDATE, GL2.ORMSTRNM
FROM GL20000 AS GL2 INNER JOIN
GL00105 AS GL105 ON GL2.ACTINDX = GL105.ACTINDX
WHERE (GL105.ACTNUMBR_2 = "010") AND (GL105.ACTNUMBR_3 = "1040")
AND (GL105.ACTNUMBR_4 = "000") AND (GL2.TRXDATE "01/1/2008") AND
(GL2.CRDTAMNT < 50000.00 and GL2.CRDTAMNT "9999.00")
--- Statement to pull in all credit amounts greater than $50,000.00
from cash account
SELECT GL105.ACTNUMST, GL105.ACTNUMBR_2, GL105.ACTNUMBR_3,
GL105.ACTNUMBR_4, GL105.ACTINDX, GL2.JRNENTRY, GL2.SOURCDOC,
GL2.REFRENCE, GL2.DSCRIPTN, GL2.TRXDATE, GL2.ACTINDX, GL2.SERIES,
GL2.CRDTAMNT, GL2.DOCDATE
FROM GL20000 AS GL2 INNER JOIN
GL00105 AS GL105 ON GL2.ACTINDX = GL105.ACTINDX
WHERE (GL105.ACTNUMBR_2 = "010") AND (GL105.ACTNUMBR_3 = "1040")
AND (GL105.ACTNUMBR_4 = "000") AND (GL2.TRXDATE "01/1/2008") AND
(GL2.CRDTAMNT "50000.00")'
I have not validated your SQL but I have used this quite a bit and works
great! I hope that helps.
I am now receiving the following error
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'cursor'.
Msg 170, Level 15, State 1, Line 31
Line 31: Incorrect syntax near 'c_company'.
I attempted to run this on Master database and test database both
Best regards,
--
MG.-
Mariano Gomez, MIS, MCP, PMP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com
The Dynamics GP Blogster at http://dynamicsgpblogster.blogspot.com
"GPNut" wrote:
> > > > > --Script for pulling between 9999.00 and 50000.00 from Cash account..
> >
> > > > > SELECT GL105.ACTNUMBR_2, GL105.ACTNUMBR_3, GL105.ACTNUMBR_4,
> > > > > GL105.ACTINDX, GLGL2.JRNENTRY, GL2.SOURCDOC, GL2.REFRENCE,
> > > > > GL2.DSCRIPTN, GL2.TRXDATE, GL2.ACTINDX, GL2.SERIES, GL2.CRDTAMNT,
> > > > > GL2.DOCDATE, GL2.ORMSTRNM
> > > > > FROM GL20000 AS GL2 INNER JOIN
> > > > > GL00105 AS GL105 ON GL2..ACTINDX = GL105.ACTINDX
> > > > > WHERE (GL105.ACTNUMBR_2 = '010') AND (GL105.ACTNUMBR_3 = '1040')
> > > > > AND (GL105.ACTNUMBR_4 = '000') AND (GL2.TRXDATE > '01/1/2008') AND
> > > > > (GL2.CRDTAMNT < 50000.00 and GL2.CRDTAMNT > '9999.00')
> >
> > > > > --- Statement to pull in all credit amounts greater than $50,000.00
> > > > > from cash account
> >
> > > > > SELECT GL105.ACTNUMST, GL105.ACTNUMBR_2, GL105.ACTNUMBR_3,
> > > > > GL105.ACTNUMBR_4, GL105.ACTINDX, GL2.JRNENTRY, GL2.SOURCDOC,
> > > > > GL2.REFRENCE, GL2.DSCRIPTN, GL2.TRXDATE, GL2.ACTINDX, GL2.SERIES,
> > > > > GL2.CRDTAMNT, GL2.DOCDATE
> > > > > FROM GL20000 AS GL2 INNER JOIN
> > > > > GL00105 AS GL105 ON GL2..ACTINDX = GL105.ACTINDX
If i paste in my SQL Statement I will receive the same results, where
do i enter the script that runs on all companies
http://blogs.msdn.com/developingfordynamicsgp/archive/2008/11/03/running-sql-commands-against-all-gp-company-
databases.aspx
If you have a *.sql file, the method in my first post is probably better: