Wrox Programmer Forums
|
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
 
Old July 1st, 2006, 02:17 AM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default sql query not working !!

hi !!

following SQL query is not working on SQL Server

"Select * from myTable Where True"

this query gives error "Incorrect syntax near 'True'" on SQLServer
but on MS Access this query works without error !!

Pl. help me out

SPD







 
Old July 1st, 2006, 07:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

The WHERE clause in SQL contains a list of search conditions. Each search condition is made up of one or more predicates. And, a predicate is an expression which evaluates to TRUE, FALSE, or UNKNOWN. The only way to generate this boolean value is by evaluating an expression. Thus in your situation you'll need to provide an expression which always evaluates to TRUE, such as:

Select * from myTable Where 1 = 1

The fact that Access allows the string 'True' to be interpreted as a boolean value is interesting, but nobody ever said that Access was truly an SQL standard implementation. Far from it, in fact...

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old July 1st, 2006, 07:38 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You're right about Access not being standard SQL but in the original SQL it is not treating a string as True, that would be Select * from myTable Where 'True'. In Access you are allowed to use VBA in queries and in VBA True is a constant evaluating to true.

--

Joe (Microsoft MVP - XML)
 
Old July 1st, 2006, 10:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yup, my bad. The 'true' in there was not a string and I misspoke. In SQL it's not a reserved word either, so the query could not be parsed, resulting in the original syntax error.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old July 10th, 2006, 02:28 AM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I THINK THE SYNTEX IS NOT RIGHT. YOU HAVE TO STATE WHAT'S EQUEL TO true.
Example
SELEC * FROM mytableName WHERE paid= true

NOTE: "paid" must be field in your table.
I hope it will work for you.

 
Old July 15th, 2006, 12:41 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also as a suggestion avoid using where equal to "true" in vb their numberic value for true is different to sql as well as other applications. Thus true is not always equal to true if you go between applications (vb to sql) for example. I suggest you use a bit and determine which is true 0, or 1 for your application because between the tools it's not consistent even within MS apps.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Query Not Working Odifius BOOK: Beginning Access VBA 0 September 20th, 2006 11:33 AM
Delete query not working Mitch PHP Databases 4 January 4th, 2006 08:00 AM
Delete Query not working kbonney98 Access 1 April 14th, 2005 06:29 AM
Help to expand a working query mat41 SQL Language 6 February 10th, 2005 05:10 AM
Query String not working!!!!!!! cmiller Beginning PHP 1 December 16th, 2003 12:30 PM





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