Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 MSDE (2000)
 very weird SELECT error

Author  Topic 

DanLynn
Starting Member

1 Post

Posted - 2005-09-15 : 11:12:19
This is the weirdest and most simple error I have ever seen in my 5+ years of SQL experience. Hopefully someone has run into this before. I am getting a query timeout when including a specific column in a select statement, but no timeout when I do "select *". I'll paste in queries that work, as well as queries that don't work. When I include by name the column "invoice_finalised" the query times out. When I include invoice_finalised and remove *any other column* it works fine (<0.1s). When I do "select * from invoice" it runs fine. The problem seems to be when I use the column by name. This is terribly confusing. Thanks for any help you guys can offer.

Works:

select invoice_id, customer_code, invoice_creation_ts, invoice_created_by, customer_invoice_code, total_items, total_weight, invoice_total from dbo.invoice

select * from dbo.invoice

select invoice_finalised, invoice_id, ((((customer_code removed)))) invoice_creation_ts, invoice_created_by, customer_invoice_code, total_items, total_weight, invoice_total from dbo.invoice

select invoice_finalised, use_shipping_address, invoice_id, customer_code, invoice_creation_ts, invoice_created_by, customer_invoice_code, total_items, total_weight, invoice_total from dbo.invoice

DOESN'T work (just times out):

select invoice_finalised, invoice_id, customer_code, invoice_creation_ts, invoice_created_by, customer_invoice_code, total_items, total_weight, invoice_total from dbo.invoice


Below is my table creation statement. There are only two rows in the table, and the offending bit column (invoice_finalised) is set to 1 for both rows. Does this make sense to anyone?


CREATE TABLE [invoice] (
[invoice_id] [int] NOT NULL ,
[customer_code] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[invoice_creation_ts] [datetime] NULL ,
[invoice_created_by] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[current_gold_fix_gram] [decimal](6, 2) NULL ,
[invoice_processed_by] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[shipping] [decimal](6, 2) NULL ,
[customer_invoice_code] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[total_items] [int] NOT NULL CONSTRAINT [DF_invoice_total_items] DEFAULT (0),
[total_weight] [decimal](6, 2) NOT NULL CONSTRAINT [DF_invoice_total_weight] DEFAULT (0.0),
[invoice_total] [decimal](18, 2) NOT NULL CONSTRAINT [DF_invoice_invoice_total] DEFAULT (0.00),
[logged_in_user] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_invoice_logged_in_user] DEFAULT (''),
[invoice_notes] [varchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[invoice_finalised] [bit] NOT NULL CONSTRAINT [DF_invoice_invoice_finalised] DEFAULT (0),
[use_shipping_address] [bit] NOT NULL CONSTRAINT [DF_invoice_use_shipping_address] DEFAULT (0),
CONSTRAINT [PK_invoice] PRIMARY KEY CLUSTERED
(
[invoice_id]
) ON [PRIMARY]
) ON [PRIMARY]

SamC
White Water Yakist

3467 Posts

Posted - 2005-09-15 : 13:38:42
UPDATE STATISTICS

... and try again

If the problem persists, take a look at the execution plans...
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-09-15 : 13:41:18
How fast does the query run from Query Analyzer? If it is fast, then the problem is within your application.

Tara
Go to Top of Page
   

- Advertisement -