Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Crystal Reports or SQL to Solve this problem.....?

Posted on 2013-10-23
4
Medium Priority
?
433 Views
Last Modified: 2013-10-23
I have the following two columns. I do not know if it is best to do this in the SP or in Crystal Reports. Currently the report uses an SP which Crystal REports points to. The MAC_CD is the Parameter used to pull records by users. They now want to switch and use the RAMS_CD....
One problem is when users pull the RAMS_CD 413000 it needs to return results for both MAC_CD 130 and 131.....How do I do that
Second problem....the MAC_CD has many extra codes not visible in the list that have Letters like S or P etc. If I need to get the following records matched up so that in the future the RAMS and MAC codes always pull the proper results back. How do I do that.
By the way the MAC codes are old and the RAMS codes are new. Your help is appreciated.

RAMS_CD	MAC_CD
413000	130
413000	131
413021	132
413031	133
415000	321
422000	220
450000	501
470000	700
471000	711
472000	721
473000	730
475000	751
485000	851
487000	870
489000	891
490000	901
491000	910
492000	921
494000	941
496000	960
498000	980
499000	990

Open in new window

0
Comment
Question by:ruavol2
  • 2
  • 2
4 Comments
 
LVL 41

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 2000 total points
ID: 39594187
This is best done in SQL.  For the most part I always do as much of the row / grouping logic in sql and let crystal be the display formatter.

do you have a mapping table . . . if not you'll need to create one (see below).
The mac column can be varchar so that your records would always match.

At the end of the day it's just a matter of:

1)  change the parameter to be Rams_CD
2)  Create the mapping table if your don't have it.
3)  Change your table joins

eg:

select * from <tbl> where MAC_CD  = @mac_cd

becomes

select * from MappingTable m
join <tbl> t on m.Mac_Cd = t.Mac_Cd
where m.RAMS_CD = @rams_cd
0
 

Author Comment

by:ruavol2
ID: 39594381
Here is a question. If I have  the two columns in the table which do I make a primary key in the table. RAMS_CD or the MAC_CD or do I need something else.

I just created a table in SQL server.

I do not see where to give the table a name other than to save as Table 1
I have the records in an Excel Spreadsheet can I import them as they are above.
0
 
LVL 41

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 39594764
You would actually make both columns the primary key . . . you only want one combination of the RAMS_CD to MAC_CD.

(EG: you don't want
413000      130
413000      130
)


After you create the table, you could edit the top N rows and then copy and paste from excel.
0
 

Author Closing Comment

by:ruavol2
ID: 39595691
Very helpful thank you sir.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

886 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