Solved

Help with SQL pseudo-code

Posted on 2014-04-25
5
3,140 Views
Last Modified: 2014-04-25
Hi,
  Could someone help me put basic SQL pseudo code to perform the following steps?  Can be general. I just need to get the syntax and functional logic in place then I can finish the specifics later.
Thanks in Advance...

- Put counts in temp table
      - 1 for bulk
      - 1 for others
- Verify temp table counts against imported counts
- If not bulk
      - export to mm table
      - Run mm job to import from sql to mm
      - Loop thru temp table for each PP
            - Edit mm job
            - Run mm job
      - Run mm job to export from mm to sql
- If not bulk update IMB for all but pp8
-      Insert records from mm table to live table
            - 1 for bulk
            - 1 for others
- Update live table
            - 1 for bulk
            - 1 for others
- If not bulk create signoff table
0
Comment
Question by:tesla764
  • 3
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40022864
as many of the "terms" are not clear to what they refer to, it's unlikely to get anything "good" without just guessing.

for example Put counts in temp table
      - 1 for bulk ...

what does " 1 for bulk " refer to?  I could guess 1 table named "bulk" ...

- Verify temp table counts against imported counts is not clear on what "imported counts" is meaning ? other table? ...

and so on and so forth...
0
 

Author Comment

by:tesla764
ID: 40022984
All I am trying to see is, for example, what would the SQL code look like to perform...

Put counts in temp table
      - 1 for bulk
      - 1 for others
- Verify temp table counts against imported counts

SQL code to create two temp tables - 1 temp table named bulk and a second named others.
SQL code to verify the temp table counts against counts that are imported, and so on. I need SQL code examples to perform everyone of the listed steps. I will do the fine tuning for our system once I can see how these steps can be coded correctly, including syntax.
Thanks.
0
 

Author Comment

by:tesla764
ID: 40023055
May be I should break this down into smaller individual functions.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40023127
yes, good idea, to check out each individual sql syntax.

I mean, when you refer to "count", the number of rows of a table would be:
SELECT COUNT(*) FROM yourtable

however, if you want the count of distinct values, or counts as per some "value", the syntax will differ...
to insert that into a temp table INSERT INTO sometable SELECT ...


then: compare with ... in t-sql, you don't just "compare", but you do something ...
for example, if you have 2 rows (same table or different tables is just a matter of syntax...), and you want to "do something" if you have at least 1 "mismatch"
DECLARE @c INT
SELECT @c = COUNT(*) FROM table1 JOIN table2 ON ... WHERE table1.somefield <> table2.somefield
if @c <> 0
begin
   -- do something here
end 

Open in new window


or update some table from those temp tables:
http://www.experts-exchange.com/Database/Miscellaneous/A_1517-UPDATES-with-JOIN-for-everybody.html

reading the high-level description, you actually might want to run a MERGE statement, and not all that complex code:
http://msdn.microsoft.com/de-de/library/bb510625.aspx
0
 

Author Closing Comment

by:tesla764
ID: 40023359
Thanks for your help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question