all groups > sql server (alternate) > october 2003 >
You're in the

sql server (alternate)

group:

select problems


select problems steve stevo
10/30/2003 7:55:31 PM
sql server (alternate):
strSearch is a dynamically created search string

Copy of select statement below

sql = "SELECT
Master.Master_Key,Master.First_App,Original_Info_Date,Last_Info_Date,Area.Ar
ea_Name
AS Area_Name, State_Cntry.State_Cntry_Name, Company.Oper_Name1 AS
Oper_Name1, Company.Oper_Name2 AS Oper_Name2, " _
& " Company.Oper_Name3 AS Oper_Name3, Location.City AS City,
Projects.Project_Name AS Project_Name, " _
& " Expansion.Expansion_Code AS Expansion_Code,
Master.Cap_Size AS cap_size, Cap.Cap_Unit AS Cap_Unit, Master.Cost AS
Cost, " _
& " Master.Status AS Status, Master.Estimated_Year_Completed
AS Estimated_Year_Completed " _
& " FROM Master INNER JOIN " _
& " Area ON Master.Area_Key = Area.Area_Key INNER JOIN " _
& " Company ON Master.Company_Key = Company.Company_Key INNER
JOIN " _
& " Location ON Master.Location_Key = Location.Location_Key
INNER JOIN " _
& " Expansion ON Master.Expansion_Key =
Expansion.Expansion_Key INNER JOIN " _
& " Cap ON Master.Cap_Key = Cap.Cap_Key INNER JOIN " _
& " Projects ON Master.Project_Key = Projects.Project_Key
INNER JOIN " _
& " State_Cntry ON Location.State_Cntry_Key =
State_Cntry.State_Cntry_Key " _
& " WHERE " & strSearch _
& " ORDER BY Area.Area_Key, State_Cntry_Name,Oper_Name1,City"


The table I need to access is called LEC

LEC_Key (PK)
Master_Key - Database Master Key
Company_Key - matches the company
LEC_Type_Key - 3 types per company (values L,E or C)

Each Master Key will have 3 values in the table, one each of L,E and C

Hope this makes some sort of sense

Thanks in advance

Simon Christie


Re: select problems sql NO[at]SPAM hayes.ch
10/31/2003 12:20:10 AM
[quoted text, click to view]

What is your actual question/problem? By the way, you'll probably get
a better response if your SQL is just SQL, with no VB or other
language around it - that makes it a lot easier to read. Including
CREATE TABLE statements for the relevant tables is also considered
helpful.

Re: select problems jbellnewsposts NO[at]SPAM hotmail.com
10/31/2003 12:23:53 AM
Hi

[quoted text, click to view]

Unfortunately it doesn't! Although you have posted pseudo DDL for your
LEC table it is better to use the scripting options in Enterprise
Manager or Query Analyser to produce actual Create table statements.
Example data as insert statements for each table would be useful,
along with the expected output you require from that data.

Regarding the SELECT statement, it would make it shorter and easier to
read if you used table aliases and removed the unnecessary column
aliases. Not all you columns are pre-fixed with the table name which
could cause you problems.

HTH

John
[quoted text, click to view]
AddThis Social Bookmark Button