Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 2 table name city and state:
city table field:
city_id,city_name,state_id

state table field:
state_id,state_name,country_id

i create store procedure:
SQL
ALTER PROCEDURE [dbo].[testreport]
AS
BEGIN
    select * from City_master
    union
    select * from State_master
END



when i add this to crystal report
only city_master column are display in database field

how can i see all 6 of column in database field


i does not know more about crystal report

thanks in advance.....
Posted
Comments
priyanshbhaliya 8-Dec-13 10:18am    
can i use to different store procedure????
1 for state
2 for city
JoCodes 8-Dec-13 10:42am    
To use Union operator you should have same column names...Use a join instead
[no name] 8-Dec-13 10:54am    
Union in conjunction with select * is a bad idea anyway

Union Operator wont solve your problem .

You should use Join operator
 
Share this answer
 
Comments
[no name] 8-Dec-13 10:55am    
Union in conjunction with select x.* is a bad idea anyway
priyanshbhaliya 8-Dec-13 11:12am    
ok
[no name] 8-Dec-13 11:43am    
Excuse me please, that was a little superficial.What I like to say is, with union I prefer to list the fields of both seletcs explicitly.
JoCodes 8-Dec-13 23:52pm    
Union needs to satisfy conditions such as number of fields, datatype, fields etc to be same in both the tables.
For Crystal report instead of using store procedure you can use View also.
Please try following code:
SQL
CREATE VIEW [dbo].[vw_testreport]
AS
select c.*,s.state_name,s.country_id from City_master c
inner join State_master s
on s.state_id=c.state_id
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900