Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > Reporting Services
Reporting Services SQL Server Reporting Services. Please specify which version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Reporting Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 14th, 2006, 05:10 AM
Registered User
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to pass Table Name as a parameter in SQL query

I have developed a report project in SQl reporting services 2005.
In Query to generate report, i am passing table name in FROM clause as a parameter.
In other words, i would select table name from a droopdown from .aspx form and from that page i pass selected table name as a paremeter to report.

i am tring to use dynamic query but i cant find solution.

Please Help me Someone.

Old October 13th, 2006, 04:08 PM
Authorized User
Join Date: Aug 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to barmanvarn

If I understand you correctly, you could do it like this. First, create a stored procedure as the data source of your report and set it up to expect a parm called "@TableName". (Now all you need is a dynamic sql statement inside your stored procedure.) Next create a parm named "@sql" as a string. Then, set @sql = 'select col1, col2 from '+@tablename. Finally just do: "Exec (@sql)" Hope this helps.

Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement in SQL Pass Through Query Coby Access VBA 3 February 15th, 2008 09:24 AM
How to pass parameter value to CR SQL Command vijaykumartaduri BOOK: Professional Crystal Reports for VS.NET 3 July 31st, 2007 12:13 AM
SQL Server StoredProcedure Parameter pass erictamlam C# 2005 3 March 27th, 2007 01:31 AM
Pass Crystal parameter to a SQL sp cphspain Crystal Reports 5 January 27th, 2005 07:03 AM
Pass-Through SQL Insert Query bmwbear Access 1 October 18th, 2004 12:43 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.