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
 SQL Server Development (2000)
 which faster ?

Author  Topic 

GenerationWithoutName
Starting Member

26 Posts

Posted - 2003-01-23 : 09:06:49
I have 2 tables :
CREATE TABLE tblCM
( CMNo varchar(10) NOT NULL PRIMARY KEY CLUSTERED,
CMDate smalldatetime NOT NULL,
PONo varchar(10) DEFAULT('') NULL --Cross References to tblPO .....
)
CREATE TABLE tblPO
( PONo varchar(10) NOT NULL PRIMARY KEY CLUSTERED,
PODate smalldatetime NOT NULL,
CMNo varchar(10) NOT NULL,
CONSTRAINT FK_CMNo FOREIGN KEY (CMNo)
REFERENCES tblCM (CMNo)
)
CREATE UNIQUE INDEX IDX_CMNo ON tblPO (CMNo)
GO
CREATE INDEX IDX_PONo ON tblCM (PONo)
GO

tblCM.PONo=tblPO.PONo for each CMNo which posted into tblPO
so what faster ?
1. SELECT c.CMNo, CONVERT(varchar(10), c.CMDate, 103) AS CMDate
FROM tblCM AS c LEFT OUTER JOIN tblPO AS p ON c.CMNo=p.CMNo
WHERE c.CMNo IS NULL
2. SELECT c.CMNo, CONVERT(varchar(10), c.CMDate, 103) AS CMDate
FROM tblCM AS c WHERE c.PONo=''

thank's All

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-01-23 : 09:18:39
#2

Although, this should be only one table...

You can't enforce DRI with this schema ...

Jay White
{0}
Go to Top of Page

GenerationWithoutName
Starting Member

26 Posts

Posted - 2003-01-27 : 06:14:36
if and if there is 2 tables like this, which faster...

DIJE
Go to Top of Page
   

- Advertisement -