Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| 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 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
  #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.



  #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

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

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