Here's my carefully hand-crafted SQL:
SELECT *
FROM tblMailbookQueryISPRO
WHERE ((fldClosed = -1)
AND (fldCSNo LIKE N'%PSH%')
AND (fldReceivedDate >= CONVERT(DATETIME,'2003-04-01 00:00:00', 102))
AND (fldReceivedDate <= CONVERT(DATETIME,'2003-04-30 23:59:59', 102))
AND (fldAction = -1)
AND ((fldActionBy1ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}') OR
(fldActionBy2ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}')))
I paste it into the SQL pane of my Data in Table window and here's the
pig's breakfast that SQL Server makes when I click "Verify SQL"
SELECT *
FROM tblMailbookQueryISPRO
WHERE (fldClosed = - 1)
AND (fldCSNo LIKE N'%PSH%')
AND (fldReceivedDate >= CONVERT(DATETIME, '2003-04-01 00:00:00', 102))
AND (fldReceivedDate <= CONVERT(DATETIME, '2003-04-30 23:59:59', 102))
AND (fldAction = - 1)
AND (fldActionBy1ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}')
OR (fldClosed = - 1) AND (fldCSNo LIKE N'%PSH%')
AND (fldReceivedDate >= CONVERT(DATETIME, '2003-04-01 00:00:00', 102))
AND (fldReceivedDate <= CONVERT(DATETIME, '2003-04-30 23:59:59', 102))
AND (fldAction = - 1)
AND (fldActionBy2ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}')
Now, what's all that about?
TIA
Edward
TABLE DEFINITION:
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[tblMailbookQueryISPRO]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[tblMailbookQueryISPRO]
GO
CREATE TABLE [dbo].[tblMailbookQueryISPRO] (
[fldCSID] uniqueidentifier ROWGUIDCOL NOT NULL ,
[fldReceivedDate] [smalldatetime] NULL ,
[fldAction] [smallint] NULL ,
[fldUserID] [uniqueidentifier] NULL ,
[fldAddressee] [nvarchar] (7) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldSubject] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldActionBy1ID] [uniqueidentifier] NULL ,
[fldActionBy2ID] [uniqueidentifier] NULL ,
[fldRemarks] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldCustomerReference] [nvarchar] (25) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[fldCSNo] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[fldEnquiryID] [uniqueidentifier] NULL ,
[fldDocID] [int] NULL ,
[fldAttachedfile] [nvarchar] (255) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[fldFileAttached] [smallint] NULL ,
[fldRecTime] [smalldatetime] NULL ,
[fldCompanyID] [uniqueidentifier] NULL ,
[fldContactID] [uniqueidentifier] NULL ,
[fldSortNo] [int] NULL ,
[fldUser] [nvarchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[fldEnq_Type] [nvarchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldTempContactID] [int] NULL ,
[fldTempCompanyID] [int] NULL ,
[fldTempOldCSID] [int] NULL ,
[fldContact] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldCustomer] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldAircraftID] [uniqueidentifier] NULL ,
[fldSystemID] [uniqueidentifier] NULL ,
[fldPartNo] [nvarchar] (18) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[fldCategoryID] [uniqueidentifier] NULL ,
[fldDescription] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[fldClosedDate] [smalldatetime] NULL ,
[fldRespSiteID] [uniqueidentifier] NULL ,
[fldReceivedTime] [nvarchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldEndTime] [nvarchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[fldClosed] [smallint] NULL ,
[fldEnquiryDate] [smalldatetime] NULL ,
[fldISPRO] [smallint] NULL ,
[fldAircraft] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldSystem] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[fldComplaint_Category] [nvarchar] (5) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[fldDocumentID] [uniqueidentifier] NULL ,
[fldComplaint] [smallint] NULL ,
[fldSerialNumber] [nvarchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[fldISPRONo] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldDate] [smalldatetime] NULL ,
[fldRevision] [nvarchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldRevisionDate] [smalldatetime] NULL ,
[fldTitle] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[fldActionRequired] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[fldStatus] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[fldOriginator] [nvarchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldOriginatorID] [uniqueidentifier] NULL ,
[fldSRP_TFU] [nvarchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[fldSRP_TFUDate] [smalldatetime] NULL ,
[fldCostToFix] [money] NULL ,
[fldCostNotToFix] [money] NULL ,
[fldActionTaken] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[fldOldCSID] [uniqueidentifier] NULL ,
[fldKnowledgeBase] [smallint] NULL ,
[fldKBSubject] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[fldKBDescription] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[fldKBFileAttached] [smallint] NULL ,
[fldKBAttachedFile] [nvarchar] (255) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[fldKBSolution] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[fldKBPublished] [smalldatetime] NULL ,
[fldKBKeyPhrase] [nvarchar] (255) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[fldQueryVisibleToCustomer] [smallint] NULL ,
[fldLastUpdateActionBy1] [smalldatetime] NULL ,
[fldLastUpdateActionBy2] [smalldatetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO 8 2837
I suddenly realized you were not working in QA, and I don't understand
what you've been doing. If you tried creating a view, I pasted the query
in the SQL pane, and nothing was changed.
Were are you trying to do this?
Tnx,
Hans Brouwer
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
This is strange indeed.
I created the table in PUBS on a server with sp3 installed. Did NOT fill
the table with data. Pasted your query into QA, clicked verify query
and...
nothing was changed.
This happens everytime you do this?
Have you tried this on another server? Another database?
Tnx,
Hans Brouwer
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
hansje <ha*****@anonymous.com> wrote in message news:<3f*********************@news.frii.net>... I suddenly realized you were not working in QA, and I don't understand what you've been doing. If you tried creating a view, I pasted the query in the SQL pane, and nothing was changed. Were are you trying to do this?
Tnx,
Hans Brouwer
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
No, not QA.
Open EM, select the server node, get down to the database, select the
table tblMailbookQueryISPRO, right-click and go to Open Table ->,
Query.
HTH
Edward
--
The reading group's reading group: http://www.bookgroup.org.uk te********@hotmail.com (Edward) wrote in message news:<25**************************@posting.google. com>... Here's my carefully hand-crafted SQL:
SELECT * FROM tblMailbookQueryISPRO WHERE ((fldClosed = -1) AND (fldCSNo LIKE N'%PSH%') AND (fldReceivedDate >= CONVERT(DATETIME,'2003-04-01 00:00:00', 102)) AND (fldReceivedDate <= CONVERT(DATETIME,'2003-04-30 23:59:59', 102)) AND (fldAction = -1) AND ((fldActionBy1ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}') OR (fldActionBy2ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}')))
I paste it into the SQL pane of my Data in Table window and here's the pig's breakfast that SQL Server makes when I click "Verify SQL"
<snip>
Enterprise Manager is not a good tool for SQL development - if you're
doing something by hand, you should really be using Query Analyzer,
which is a lot more powerful and reliable.
I suspect that EM's parser is confused by your parentheses, most of
which appear to be superfluous (although I may be wrong - I looked
very quickly). Your query looks like it could probably be more clearly
written like this:
SELECT *
FROM
dbo.tblMailbookQueryISPRO
WHERE
fldClosed = -1
AND fldCSNo LIKE N'%PSH%'
AND fldReceivedDate >= '20030401'
AND fldReceivedDate < '20030501'
AND fldAction = -1
AND (fldActionBy1ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}' OR
fldActionBy2ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}')
Notice the date format as well - YYYYMMDD will work consistently with
all client/server settings which affect dates. Since the column is
already smalldatetime, the values will be converted implicitly for
you. You might be better off using datetime instead - 2079 isn't so
far away if you have to deal with transactions involving long-term
loans or leases.
Simon
Simon Hayes wrote: te********@hotmail.com (Edward) wrote in message news:<25**************************@posting.google. com>...
Here's my carefully hand-crafted SQL:
SELECT * FROM tblMailbookQueryISPRO WHERE ((fldClosed = -1) AND (fldCSNo LIKE N'%PSH%') AND (fldReceivedDate >= CONVERT(DATETIME,'2003-04-01 00:00:00', 102)) AND (fldReceivedDate <= CONVERT(DATETIME,'2003-04-30 23:59:59', 102)) AND (fldAction = -1) AND ((fldActionBy1ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}') OR (fldActionBy2ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}')))
I paste it into the SQL pane of my Data in Table window and here's the pig's breakfast that SQL Server makes when I click "Verify SQL"
<snip>
Enterprise Manager is not a good tool for SQL development - if you're doing something by hand, you should really be using Query Analyzer, which is a lot more powerful and reliable.
I suspect that EM's parser is confused by your parentheses, most of which appear to be superfluous (although I may be wrong - I looked very quickly). Your query looks like it could probably be more clearly written like this:
SELECT * FROM dbo.tblMailbookQueryISPRO WHERE fldClosed = -1 AND fldCSNo LIKE N'%PSH%' AND fldReceivedDate >= '20030401' AND fldReceivedDate < '20030501' AND fldAction = -1 AND (fldActionBy1ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}' OR fldActionBy2ID = '{ca8e0b3c-dd6e-40a6-8282-6a3ed5ce55e3}')
Notice the date format as well - YYYYMMDD will work consistently with all client/server settings which affect dates. Since the column is already smalldatetime, the values will be converted implicitly for you. You might be better off using datetime instead - 2079 isn't so far away if you have to deal with transactions involving long-term loans or leases.
Simon
But so typical of Microsoft. Code something that rewrites what the user
intended without
having the civility to ask. I wonder when my buddies up the street will
learn that it isn't nice
to do things for people without asking permission first.
--
Daniel Morgan http://www.outreach.washington.edu/e...ad/oad_crs.asp http://www.outreach.washington.edu/e...oa/aoa_crs.asp da******@x.washington.edu
(replace 'x' with a 'u' to reply)
Daniel Morgan <da******@x.washington.edu> wrote in message news:<1067612838.13871@yasure>... Simon Hayes wrote:
<snip?Enterprise Manager is not a good tool for SQL development - if you're doing something by hand, you should really be using Query Analyzer, which is a lot more powerful and reliable.
But EM *is* quite handy. You can select tables, make joins by
dragging fields from one table to another, see the relations in a nice
graphical way, and ... gulp ... I come from an Access developer
background and the Query Builder in Access was pretty good (and
clearly the template for EM's)! I suspect that EM's parser is confused by your parentheses, most of which appear to be superfluous (although I may be wrong - I looked very quickly). Your query looks like it could probably be more clearly written like this:
Ah, trying to start a Holy War, eh? Seriously, I parenthesise things
because that's how I write my code. So that it is unambiguous to
someone (else) looking at it. Sure, if you just have a string of
clauses joined by ANDs it doesn't really matter, but when you factor
in a mixture of ORs and ANDs you'll be glad of the parentheses and,
what's important, so will I when I come to maintain your code.
<snip> Notice the date format as well - YYYYMMDD will work consistently with all client/server settings which affect dates.
I work with the format returned from the application - too much hard
work to go in there and change the output.
Since the column is already smalldatetime, the values will be converted implicitly for you. You might be better off using datetime instead - 2079 isn't so far away if you have to deal with transactions involving long-term loans or leases.
I don't, but thanks for the warning. With a bit of luck I'll be
retired by 2079 and sunning myself on Mars.
But so typical of Microsoft. Code something that rewrites what the user intended without having the civility to ask. I wonder when my buddies up the street will learn that it isn't nice to do things for people without asking permission first.
This is JUST what bugged me about it. Microsoft didn't even have the
civility to inform me that it thought my code was crap, and that their
way was better. Only trouble is, having looked at quite a deal of
their sample code, I wouldn't bet on theirs being better than mine in
all circumstances. In any case, why not let us go to hell in our own
handbaskets?
But thanks to all who took the trouble to reply. It's just one of
those things, I guess.
Edward
--
The reading group's reading group: http://www.bookgroup.org.uk
"Edward" <te********@hotmail.com> wrote in message
news:25**************************@posting.google.c om... Daniel Morgan <da******@x.washington.edu> wrote in message
news:<1067612838.13871@yasure>... Simon Hayes wrote: <snip?Enterprise Manager is not a good tool for SQL development - if you're doing something by hand, you should really be using Query Analyzer, which is a lot more powerful and reliable. But EM *is* quite handy. You can select tables, make joins by dragging fields from one table to another, see the relations in a nice graphical way, and ... gulp ... I come from an Access developer background and the Query Builder in Access was pretty good (and clearly the template for EM's)!
Yes and no. One is an application. The other is a database engine with
some GUI stuff thrown on top of it.
EM IS handy, no doubt about it, but keep in mind it's masking a LOT of
stuff. Ah, trying to start a Holy War, eh? Seriously, I parenthesise things because that's how I write my code. So that it is unambiguous to someone (else) looking at it. Sure, if you just have a string of clauses joined by ANDs it doesn't really matter, but when you factor in a mixture of ORs and ANDs you'll be glad of the parentheses and, what's important, so will I when I come to maintain your code.
I tend to agree, for human readability, parenthesis are very nice. But
keep in mind, the optimizer will strip off and re-arrange things as it see
fits (keeping the truth values the same of course.) I don't, but thanks for the warning. With a bit of luck I'll be retired by 2079 and sunning myself on Mars.
Don't we all. Of course didn't all the folks in the 50s and 60s coding two
digit years. :-)
But so typical of Microsoft. Code something that rewrites what the user intended without having the civility to ask. I wonder when my buddies up the street will learn that it isn't nice to do things for people without asking permission first.
This is JUST what bugged me about it. Microsoft didn't even have the civility to inform me that it thought my code was crap, and that their way was better. Only trouble is, having looked at quite a deal of their sample code, I wouldn't bet on theirs being better than mine in all circumstances. In any case, why not let us go to hell in our own handbaskets?
I suspect (and this was just a quick pass looking at the two queries) that
somehow EM is rewriting it to present a slightly more optimized version to
the SQL Engine. As far as I could tell, truth-value-wise, they were the
same.
In any case, I would follow other folks recommendations, use Query Analyzer
or other tools to write your queries. But thanks to all who took the trouble to reply. It's just one of those things, I guess.
Edward -- The reading group's reading group: http://www.bookgroup.org.uk This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt |
last post by:
I think this is the basic concept in ASP server-side development.
My boss told me web application is NOT client-server application. I argued
with him because browser is the client, and the server...
|
by: Ray Lavelle |
last post by:
I have an application which runs in many different stores. Stores
that are within a chain want to be able to share their client lists.
I want to implement a sync process where each application...
|
by: Jeager |
last post by:
Why is it, Microsoft manage to write operating systems and office
applications with every bell and whistle facility known to man. Yet,
even after years and years of development they still cannot...
|
by: Ryan |
last post by:
I have some software (written in Delphi 5) which has been working for
several months without a problem.
I have been given a copy of the database on our development server
(SQL 7) and have...
|
by: zacware |
last post by:
Hi!
What started out as a simple test of mysql has turned into what is
quickly becoming a replacement for our entire business system and web
site
The bad news is that we are now wrestling...
|
by: Mike |
last post by:
Hi,
I am strugling with a simple problem which I can't seem to resolve.
I have an asp.net page which contains a server-control (flytreeview,
which is a kind
of a tree to be exact).
The tree is...
|
by: Anthony Malt |
last post by:
Hi,
my server has a database table. I read this table on the server into a
dataset and my client retrieves it through a webservice.
No changes on the client and server happen. What's the best...
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of...
|
by: Coldfire |
last post by:
Since i cannot show the differences in a two-column like table. I am first putting
MS SQL Server 2005 and then MySQL 5.x.
MS SQL Server 2005
Brief Overview
- SQL Server is a full-fledged...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |