Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 30th, 2005, 11:07 AM
Authorized User
 
Join Date: Sep 2004
Location: , , USA.
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use Temp Table Variable in Stored Procedure

I'm playing with simple stored procedure with declared table variable as below:

Code:
CREATE PROCEDURE TEST
AS 
    Declare @myTable table
    (    
    Company varchar(10),
        Amount Money
    )
    INSERT INTO @myTable (Company, Amount)
    select company, amount from tblmonthly where company = '1234'
        select top 3††* from @mytable
return
GO
But when executing it with ADO in ASP page, it doesn't seem to return any data? Although I have no error with opening the recordset?

I use the following codes to do this:

Code:
        Set cmd = CreateObject("ADODB.Command")
        Set rs = CreateObject("ADODB.Recordset")
        cmd.ActiveConnection = adoCnn
        cmd.CommandText = "TEST"
        cmd.CommandType = adCmdStoredProc
        set rs = cmd.Execute

Is there any issue I need to take care of? It seems to have something to do with the table variable?
Reply With Quote
  #2 (permalink)  
Old March 30th, 2005, 03:35 PM
Authorized User
 
Join Date: Sep 2004
Location: , , USA.
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Answering my own question and for others who might benefit:

This is what I need to do, I added "SET NOCOUNT ON" in the beginning of the stored procedure to send back a closed recordset.

Reply With Quote
  #3 (permalink)  
Old April 15th, 2011, 03:50 PM
Registered User
 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default solution

I wrote a post about this a while ago - you essentially need to form the sql statement first by declaring a long varchar and then executing it.

http://www.geakeit.co.uk/2011/02/05/a-table-input-variable-in-a-stored-procedure-and-bypassing-must-declare-the-table-variable-msg-1087/
Reply With Quote
Reply


Thread Tools
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, temp table kumiko SQL Language 2 January 15th, 2008 04:46 AM
Add new Table to Stored Procedure pallone SQL Server 2000 2 February 14th, 2007 11:58 AM
Stored Procedure That Updates Table GailCG Classic ASP Professional 1 January 22nd, 2006 12:11 PM
Passing Variable MS Proj to SQL Stored Procedure Abaxt Access VBA 2 July 7th, 2005 11:05 AM
Build a table from a Stored Procedure rogue248 SQL Server 2000 2 October 7th, 2004 10:06 PM



All times are GMT -4. The time now is 08:59 AM.


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