Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 November 14th, 2005, 04:25 PM
Registered User
Join Date: Sep 2003
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Temp Table Query not returning results to page

 I am using the following query from an ASP page:

select Orders.CustID
into #TempTable
from Orders
join Customers
on Orders.CustID = Customers.CustID
group by Orders.CustID
having count(Orders.CustID) = 1

select count(*) as NewCustomers
from #TempTable t
join Orders o
on t.CustID = o.CustID
where cast(convert(char(10), OrderDateTime, 112) as smalldatetime) = cast(convert(char(10), '11/10/2005', 112) as smalldatetime)

drop table #TempTable

When I run this in Query Analyzer it works fine and returns a column called "New Customers". However, when I run it from the ASP page or even as a stored procedure, the column is not available. Can anyone help me with this? Thanks.
  #2 (permalink)  
Old November 15th, 2005, 04:50 PM
Friend of Wrox
Join Date: Aug 2004
Location: Orange County, CA, USA.
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts

I suspect that there may be a problem with your dynamic type of data returned. I suggest trying to force the count(*) as a particular data type. Not allowing SQL to determine the data type. I have seen many times when you run something in SQL it works but doesn't in a front end app when the data type is not explicit. May want to try something like NewCustomers = convert(varchar(24),count(*)) to see if this is the issue. SQL won't care if the data type changes because it's only displaying it in a query window but the recieving application generally needs a consistent data type. Also if this solves your problem let me know so I don't have to test it.


Similar Threads
Thread Thread Starter Forum Replies Last Post
temp table in query abdusalam Access 5 January 9th, 2008 09:28 AM
Returning Stored Procedure Results from ASP page JennaAckerson Classic ASP Basics 0 December 23rd, 2005 11:44 AM
Query returning 0 results although SQL is valid aquagal77 Classic ASP Databases 4 March 31st, 2005 11:06 AM
Returning Oracle SELECT query results to DataSet gp_mk ADO.NET 0 December 17th, 2003 11:08 AM
Query not returning correct results from database Jams30 PHP Databases 5 November 7th, 2003 08:55 AM

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