Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 25th, 2005, 06:13 PM
Authorized User
Join Date: Jul 2004
Location: Bellevue, WA, USA.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can you pass a table to a store procedure?


I want to pass a table to a MS SQL Server stored procedure. Can this be done? Can you pass a data set with a talbe? I have multi-dimension (2 column) data that I want to save to the database.



Reply With Quote
  #2 (permalink)  
Old January 26th, 2005, 01:43 PM
Friend of Wrox
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc

you can not pass the table name directly. Using dynamic SQL can give you the needed results

                 CREATE PROCEDURE passtable_name @table varchar(50) 
                 DECLARE @sql_string VARCHAR(200) 
                 DECLARE @total FLOAT 
                 SELECT @sql_string="SELECT SUM(cost) FROM "+ @table 
                 exec (@SQL_STRING)

Jaime E. Maccou
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Store procedure help... RinoDM SQL Server 2000 7 August 11th, 2008 07:09 PM
store procedure, temp table kumiko SQL Language 2 January 15th, 2008 05:46 AM
Store Procedure sureshyuga SQL Server 2000 0 May 18th, 2007 01:49 AM
How can I refresh a table in store procedure flyfish SQL Server 2000 1 July 19th, 2005 07:01 PM
Pass parameter to store procedure & Crystal Report quinn Classic ASP Professional 0 March 10th, 2004 02:16 PM

All times are GMT -4. The time now is 11:36 PM.

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