Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All
How we can assign column of table to Crystal report using sql query.
Means sql query is varying w.r.t purpose.

Ex: Some times select * from table or
Some times select column1,column2 from table. Like that
Have you any solution let me know.
Posted

1 solution

Well I would use dynamic sql to build it up(your question asks 'sql query' so i am staying away from code here), with a stored proc in your crystal report, that takes the parameters as columns EG:

Create proc myprocname
(
@columns varchar(400),
@table varchar(50)
)
AS
Declare @sql varchar(500)
Set @sql = 'SELECT ' + @columns + ' FROM ' + @table
EXEC @sql


(you will need to modify this thinking to suit your needs)

some extra reading here: http://msdn.microsoft.com/en-us/library/ms188001.asp[^]
 
Share this answer
 

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