All Crystal

All Crystal
All Crystal

How do you use UNION ALL in Crystal Reports 2008?

I'm fairly new to Crystal Reports 2008. I was given the task of compiling data saved in 100+ Excel spreadsheet. All Excel spreadsheet have same exact field/column types. Is there any way to use the UNION ALL command in Crystal 2008?

Refer to http://en.wikipedia.org/wiki/Union_(SQL) for some basic info on UNION ALL.

A UNION ALL can be used in a SQL statements to combine the results of multiple select statements. When you create your Crystal Report, you can create a custom SQL statement that uses UNION ALL.

But is this really what you want to do? Were you planning on writing a single SQL statement that performs 100+ UNION ALLs?

Why don't you take all of the Excel docs and do a "Save As" to CSV format? Then take the 100+ CSV files and combine them into a single file.

Now you can create a Crystal Report that queries one data source -- a single .CSV file -- and save yourself the headache of maintaining a monster-size SQL statement.

Here's info on how to create a custom SQL query in a Crystal Report:

Defining an SQL Command
==================

If the database you are using supports a query language such as SQL, you can write your own command which will be represented in Crystal Reports as a Table object. This allows database users complete control of the data processing that gets pushed down to the database server. A user who has experience with databases and the SQL language can write a highly optimized command that can considerably reduce the size of the set of data returned from the server.

You can write your own command by using the Add Command node in the Database Expert to create a virtual table which will represent the results of processing the command. Once the command has been created, you can store it in the BusinessObjects Enterprise Repository so it can be shared between many users.

Note: Some of the Crystal Reports native database drivers do not support the Add Command feature:

* DB2 Server
* Sybase Server
* Informix Online Server

When you use a virtual table that was created as a Command, or when you use a Command from the BusinessObjects Enterprise Repository, Crystal Reports does not alter the syntax of the SQL submitted to the server (that is, it does not automatically add quoting or escape characters). This behavior also applies to parameters used in Commands. Therefore, you must add the quoting and escape characters that are necessary for your database driver.

To create a command object
--------------------
1. In the Database Expert, expand the Create New Connection folder and browse the subfolders to locate your data source.
2. Log on to your data source if necessary.
3. Under your data source, double-click the Add Command node.
4. In the Add Command to Report dialog box, enter an appropriate query/command for the data source you have opened.
For example:

SELECT
Customer.`Customer ID`,
Customer.`Customer Name`,
Customer.`Last Year's Sales`,
Customer.`Region`,
Customer.`Country`,
Orders.`Order Amount`,
Orders.`Customer ID`,
Orders.`Order Date`
FROM
Customer Customer INNER JOIN Orders Orders ON
Customer.`Customer ID` = Orders.`Customer ID`
WHERE
(Customer.`Country` = 'USA' OR
Customer.`Country` = 'Canada') AND
Customer.`Last Year's Sales` < 10000.
ORDER BY
Customer.`Country` ASC,
Customer.`Region` ASC

Note: The use of double or single quotes (and other SQL syntax) is determined by the database driver used by your report. You must, however, manually add the quotes and other elements of the syntax as you create the command.

5. Optionally, you can create a parameter for your command by clicking Create and entering information in the Command Parameter dialog box.
For more information about creating parameters, see To create a parameter for a command object.

6. Click OK.
You are returned to the Report Designer. In the Field Explorer, under Database Fields, a Command table appears listing the database fields you specified.

Note:
* To construct the virtual table from your Command, the command must be executed once. If the command has parameters, you will be prompted to enter values for each one.
* By default, your command is called Command. You can change its alias by selecting it and pressing F2.

To edit a command object
---------------------------
1. In the Selected Tables area of the Database Expert, select the command you want to edit.
2. Right-click the command and select Edit Command from the shortcut menu.
Note: If the command is stored in the BusinessObjects Enterprise Repository, you must disconnect it before editing. For more information, see Modifying objects in the repository.
3. Make the changes you want in the Modify Command dialog box and click OK when you're done.

To create a parameter for a command object
-----------------------------------------
You can create a parameter field while working in the Add Command to Report dialog box or the Modify Command dialog box.

1. In the Parameter List area of the appropriate command dialog box, click Create.
2. In the Command Parameter dialog box, enter the following information in the fields provided:
* Parameter Name
Enter the name you want to identify your parameter by.
* Prompting Text
Enter the text you want to appear when the program prompts you.
* Value Type
Select the data type of the parameter field.
* Default Value
Enter the value you want the program to use if you do not supply a new value. This is an optional step.
3. Click OK.
Your parameter is added to the Parameter List. You can modify or delete it by returning to the Modify Command dialog box.

To add a parameter to a command object
-----------------------------
1. Place the cursor in the query text in the spot where you want to insert the parameter.
2. Double-click the parameter's name in the Parameter List.
The parameter is added where your cursor is sitting. It should look like this:

WHERE
Customer.`Country` = '{?CountryParam}'

Note: You must manually add quotes and other elements of syntax as you create your command.

If you want to change the parameter field you've created, go to the Field Explorer dialog box and select it from the Parameter Fields node. See Parameter Fields and Prompts for more information.

3 Piece Jewelry Set Necklace Earrings Bracelet Curb Link 14k White Gold Overlay 3 Piece Jewelry Set Necklace Earrings Bracelet Curb Link 14k White Gold Overlay US $69.99 15m
Welforth Pink Stoned Glass Perfume Bottle PB 675 Welforth Pink Stoned Glass Perfume Bottle PB 675 US $15.00 15m
286a] Fashion Bracelet HEMATITE Plated w Lg Rhinestones NWOT 286a] Fashion Bracelet HEMATITE Plated w Lg Rhinestones NWOT US $8.00 15m
CRYSTAL CLEAR HARD CASE COVER FOR LG OPTIMUS SLIDER Q NET10 PHONE ACCESSORY CRYSTAL CLEAR HARD CASE COVER FOR LG OPTIMUS SLIDER Q NET10 PHONE ACCESSORY US $7.65 15m
Multiscale Black Dial Lancet Chronograph Snail Scale and Pulsation Scale NR Multiscale Black Dial Lancet Chronograph Snail Scale and Pulsation Scale NR US $120.00 15m
MICHAEL KORS MOTHER OF PEARL DIAL GOLD BAND WOMENS MK5305 MICHAEL KORS MOTHER OF PEARL DIAL GOLD BAND WOMENS MK5305 US $200.00 15m
AMORE LA VITA STERLING SILVER 3 D ENAMEL BALLERINA W LOBSTER CLASP CHARM AMORE LA VITA STERLING SILVER 3 D ENAMEL BALLERINA W LOBSTER CLASP CHARM US $16.99 15m
ESQ 07301223 CENTURION CHRONOGRAPH WHITE DIAL WATCH ESQ 07301223 CENTURION CHRONOGRAPH WHITE DIAL WATCH US $360.00 15m
Black Onyx Agate Pendant Polished Gemstone Necklace TrendyTreasuresByRamona Black Onyx Agate Pendant Polished Gemstone Necklace TrendyTreasuresByRamona US $23.00 15m
DG DOLCE GABBANA WOMENS DW0842 LISBON GOLD CASE SILVER DIAL WATCH DG DOLCE GABBANA WOMENS DW0842 LISBON GOLD CASE SILVER DIAL WATCH US $156.00 15m
MICKEY DIRT BIKE ©DISNEY BY LORUS ANALOG QUARTZ KIDS WATCH MICKEY DIRT BIKE ©DISNEY BY LORUS ANALOG QUARTZ KIDS WATCH US $12.50 15m
7x6 DIAMOND BLACK HOUSING PROJECTOR 7 X 6 HEAD LIGHTS LAMPSSUPER WHITE BULBS 7x6 DIAMOND BLACK HOUSING PROJECTOR 7 X 6 HEAD LIGHTS LAMPSSUPER WHITE BULBS US $31.00 15m
CRYSTAL CLEAR HARD SHELL SNAP ON CASE COVER SAMSUNG GALAXY NEXUS i515 ACCESSORY CRYSTAL CLEAR HARD SHELL SNAP ON CASE COVER SAMSUNG GALAXY NEXUS i515 ACCESSORY US $7.65 15m
6MM 14 2 3 1STRAND CRYSTAL GLASS FACETED ROUND BEADS 6MM 14 2 3 1STRAND CRYSTAL GLASS FACETED ROUND BEADS US $.99 15m
Golden Plated Sapphire Crystal Rhinestone Enamel Tail Parrot Fashion Brooch Pin Golden Plated Sapphire Crystal Rhinestone Enamel Tail Parrot Fashion Brooch Pin US $5.50 15m
KENNETH COLE KC4825 WOMENS AUTOMATIC GOLD CASE BRACELET KENNETH COLE KC4825 WOMENS AUTOMATIC GOLD CASE BRACELET US $168.75 15m
Welforth Purple Flower Perfume Bottle PB 727 Welforth Purple Flower Perfume Bottle PB 727 US $15.00 15m
Samsung SL102 102 MP Digital Camera Pink Samsung SL102 102 MP Digital Camera Pink US $50.00 16m
For Apple iPhone 4 4G 4S Silver Bling Crystal Hard Case For Apple iPhone 4 4G 4S Silver Bling Crystal Hard Case US $7.26 16m
AMORE LA VITA STERLING SILVER CZ ENAMELED SPADE CARD W LOBSTER CLASP CHARM AMORE LA VITA STERLING SILVER CZ ENAMELED SPADE CARD W LOBSTER CLASP CHARM US $29.99 16m
TIMEX EXPEDITION RUGGED FIELD CHRONOGRAPHGRAPH WHITE DIAL T49781 TIMEX EXPEDITION RUGGED FIELD CHRONOGRAPHGRAPH WHITE DIAL T49781 US $96.00 16m
Red Austrian Rhinestone Crystal Decorative Brooch Pin Red Austrian Rhinestone Crystal Decorative Brooch Pin US $2.99 16m
CUSTOM INITIAL ARGYLE PRINT Scrabble Tile Pendant Charm CUSTOM INITIAL ARGYLE PRINT Scrabble Tile Pendant Charm US $6.95 16m
FULFILLMENT Scrabble Tile Art Pendant Charm FULFILLMENT Scrabble Tile Art Pendant Charm US $6.95 16m
ELOQUENT DICTIONARY WORD DEFINITION Scrabble Pendant ELOQUENT DICTIONARY WORD DEFINITION Scrabble Pendant US $6.95 16m
NURSE RN MEDICAL PROFESSION Scrabble Tile Pendant Charm NURSE RN MEDICAL PROFESSION Scrabble Tile Pendant Charm US $7.95 16m
CUPCAKES SWEETS DESSERT Scrabble Tile Art Pendant Charm CUPCAKES SWEETS DESSERT Scrabble Tile Art Pendant Charm US $6.95 16m
OREGON PORTLAND AREA MAP Scrabble Tile Pendant Charm OREGON PORTLAND AREA MAP Scrabble Tile Pendant Charm US $6.95 16m
CAIRN TERRIER DOG BREED Scrabble Tile Art Pendant Charm CAIRN TERRIER DOG BREED Scrabble Tile Art Pendant Charm US $7.95 16m
Apple iPhone 4S Latest Model 16GB White Sprint Smartphone Factory Reset Apple iPhone 4S Latest Model 16GB White Sprint Smartphone Factory Reset US $425.00 16m
Sapphire Czech Crystal Zig Zag European Spacer Bead Fit Charm Bracelet Pp307 Sapphire Czech Crystal Zig Zag European Spacer Bead Fit Charm Bracelet Pp307 US $4.99 16m
05 09 MUSTANG RANGE ROVER STYLE LED HALO BLACK CRYSTAL HEAD LIGHTS FRONT LAMPS 05 09 MUSTANG RANGE ROVER STYLE LED HALO BLACK CRYSTAL HEAD LIGHTS FRONT LAMPS US $69.50 16m
6000K White H3 55W Xenon HID Conversion Foglight Kit 6000K White H3 55W Xenon HID Conversion Foglight Kit US $57.95 16m
12 Prim TEAPOT Soy Wax TARTS MELTS 8 ounces Pic 2 Scents Colors NEW FRAGRANCES 12 Prim TEAPOT Soy Wax TARTS MELTS 8 ounces Pic 2 Scents Colors NEW FRAGRANCES US $3.99 16m
Crazy Lace Agate Pendant Polished Gemstone Necklace TrendyTreasuresByRamona Crazy Lace Agate Pendant Polished Gemstone Necklace TrendyTreasuresByRamona US $18.00 16m
SKAGEN DENMARK WOMENS WATCH SILVER WHITE MOP DIAL 922SSSS SKAGEN DENMARK WOMENS WATCH SILVER WHITE MOP DIAL 922SSSS US $104.00 16m
Vintage Mixed Woods FISH Necklace Hand Made Painted Long Heavy Unique Vintage Mixed Woods FISH Necklace Hand Made Painted Long Heavy Unique US $12.50 16m
INVICTA WOMENS 0943 ANATOMIC SUBAQUA COLLECTION CHRONOGRAPH WATCH INVICTA WOMENS 0943 ANATOMIC SUBAQUA COLLECTION CHRONOGRAPH WATCH US $696.50 16m
Crystal Case CoverWall Charger for iPhone 3GS 16 32 GB Crystal Case CoverWall Charger for iPhone 3GS 16 32 GB US $4.04 16m
300a] Necklace Mens Pave Crystal Rhinestones Cross Pendant Chain 300a] Necklace Mens Pave Crystal Rhinestones Cross Pendant Chain US $8.69 16m
Genuine Diamond Heart Promise Sweetheart Ring Size 7 Stamped 925 Genuine Diamond Heart Promise Sweetheart Ring Size 7 Stamped 925 US $69.99 16m
DKNY NY8041 LADIES SILVER GLITZ WIDE BANGLE MOTHER OF PEARL DIAL DKNY NY8041 LADIES SILVER GLITZ WIDE BANGLE MOTHER OF PEARL DIAL US $156.00 16m
Contemporary Round Black Metal Starburst Crystal Gems Photo Picture Frame45x65 Contemporary Round Black Metal Starburst Crystal Gems Photo Picture Frame45x65 US $29.99 16m
DOLCE GABBANA DG TIME LADIES WATCH CHECK DW0340 DOLCE GABBANA DG TIME LADIES WATCH CHECK DW0340 US $236.00 16m
BROWN SMOKEY TOPAZ CITRINE 925 STERLING SILVER ARTISAN PENDANT 1 3 8 V4561 BROWN SMOKEY TOPAZ CITRINE 925 STERLING SILVER ARTISAN PENDANT 1 3 8 V4561 US $7.11 17m
DOLCE AND GABBANA DW0369 TWO TONE BLACK TACHYMETER RUBBER STRAP DOLCE AND GABBANA DW0369 TWO TONE BLACK TACHYMETER RUBBER STRAP US $476.00 17m
AMORE LA VITA STERLING SILVER CZ ENAMELED CLUB CARD W LOBSTER CLASP CHARM AMORE LA VITA STERLING SILVER CZ ENAMELED CLUB CARD W LOBSTER CLASP CHARM US $27.99 17m
Silver Tone Designer Necklace w Charms Pendants ABSOLUTELY GORGEOUS QVC NEW Silver Tone Designer Necklace w Charms Pendants ABSOLUTELY GORGEOUS QVC NEW US $14.99 17m
Silver Tone Designer Necklace w Charms Cross Pendants GORGEOUS New QVC seen Silver Tone Designer Necklace w Charms Cross Pendants GORGEOUS New QVC seen US $16.99 17m
Round Silver Tone Chain w Cross Pendant Studded with Crystals Beads GORGEOUS Round Silver Tone Chain w Cross Pendant Studded with Crystals Beads GORGEOUS US $7.99 17m
6 COLORS FABULOUS CUT TO CLEAR CRYSTAL HOCK WINE GOBLETS 6 COLORS FABULOUS CUT TO CLEAR CRYSTAL HOCK WINE GOBLETS US $129.99 17m
Disney Womens Collectible Tinker Bell Watch Disney Womens Collectible Tinker Bell Watch US $8.27 17m
GOLD HGE BEADED Crystal CHARM BRACELET ANKLET FITS 7 11 GOLD HGE BEADED Crystal CHARM BRACELET ANKLET FITS 7 11 US $2.95 17m
Invicta Reserve Subaqua Noma I Limited Edition Valjoux 7750 Chronograph 10478 Invicta Reserve Subaqua Noma I Limited Edition Valjoux 7750 Chronograph 10478 US $860.00 17m
NEW Silver CRYSTAL Bead BUTTERFLY CHARM BRACELET ANKLET FITS 7 12 NEW Silver CRYSTAL Bead BUTTERFLY CHARM BRACELET ANKLET FITS 7 12 US $2.95 17m
DEPRESSION ERA AHHEISEY CRYSTOLITE PATTERN CRYSTAL CANDLESTICK VALUE $5000 DEPRESSION ERA AHHEISEY CRYSTOLITE PATTERN CRYSTAL CANDLESTICK VALUE $5000 US $14.99 17m
318a] Necklace Hematite Plated Memory Wire TOPAZ CRYSTAL Cross 318a] Necklace Hematite Plated Memory Wire TOPAZ CRYSTAL Cross US $4.00 17m
24 piece Crystal Stemware Sherbet Champagne Rocks Glasses 24 piece Crystal Stemware Sherbet Champagne Rocks Glasses US $25.00 17m
6 piece Crystal Pinwheel Design etched star 3 Candy Dish Large Bowl and Vase 6 piece Crystal Pinwheel Design etched star 3 Candy Dish Large Bowl and Vase US $40.00 17m
99 04 F250 F350 CRYSTAL HEAD LIGHTS CORNER SIGNAL LAMPS 99 04 F250 F350 CRYSTAL HEAD LIGHTS CORNER SIGNAL LAMPS US $114.99 17m
319a] Earrings Bright GP Corner Hung Square Dangles w Crystal Borders NIP 319a] Earrings Bright GP Corner Hung Square Dangles w Crystal Borders NIP US $4.00 17m
NINTENDO Wii CONSOLE HDGAMEFIT PLUS SUPER MARIO BROS MARIO KART BUNTLE NINTENDO Wii CONSOLE HDGAMEFIT PLUS SUPER MARIO BROS MARIO KART BUNTLE US $599.01 17m
09 12 Dodge Ram 1500 2500 3500 Smoke Tint Crystal Diamond Headlights Lamps 09 12 Dodge Ram 1500 2500 3500 Smoke Tint Crystal Diamond Headlights Lamps US $154.99 17m
Sailor Anchor of Hope Crystal 925 Silver Pendant Sailor Anchor of Hope Crystal 925 Silver Pendant US $7.99 17m
Print on Canvas by Percy Dalton Lowering Boats STUNNING Print on Canvas by Percy Dalton Lowering Boats STUNNING US $79.99 17m
Clear Crystal Snap on Hard Skin CaseCar Charger For Motorola Atrix 2 MB865 Clear Crystal Snap on Hard Skin CaseCar Charger For Motorola Atrix 2 MB865 US $5.12 17m
Wide Fisheye lens for canon eos rebel t3 t3i T2i T1i 550D 500D 1000D XS 450D XSi Wide Fisheye lens for canon eos rebel t3 t3i T2i T1i 550D 500D 1000D XS 450D XSi US $37.95 17m
Priday Plume Agate Pendant Polished Gemstone Necklace TrendyTreasuresByRamona Priday Plume Agate Pendant Polished Gemstone Necklace TrendyTreasuresByRamona US $20.00 17m
Wide Angle Macro Fisheye lens for NIKON d5100 d5000 d3100 d3000 d40x as 28 35mm Wide Angle Macro Fisheye lens for NIKON d5100 d5000 d3100 d3000 d40x as 28 35mm US $39.99 17m
RQ19 ROSE PINK Quartz crystal Brasil mineral crystal specimens from BRASIL RQ19 ROSE PINK Quartz crystal Brasil mineral crystal specimens from BRASIL US $3.99 17m

Post a Comment

Your email is never shared. Required fields are marked *

*
*