﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server Newbies  / syntax error in select distinct / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 08:04:39 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: syntax error in select distinct</title><link>http://www.sqlservercentral.com/Forums/Topic582768-1291-1.aspx</link><description>From a quick look it looks like this statement may be casuing you some problems[code]set rs = conntemp.execute("SELECT SQLStmt, DateEntered FROM SavedSearch WHERE ID=" &amp; SavedSearch)[/code]As you SQLstmnt  already has the FROM Clause it will error when you try and combine it with another FROM clause.Are you to provide the SQL statement that is sent to the sever? (with actual values and not variables in it) </description><pubDate>Wed, 08 Oct 2008 11:20:52 GMT</pubDate><dc:creator>steveb. </dc:creator></item><item><title>syntax error in select distinct</title><link>http://www.sqlservercentral.com/Forums/Topic582768-1291-1.aspx</link><description>Hi, I'm relatively new to sql server and asp, and am having an issue with a particular piece of code.basically I'm getting a syntax error at line 498 of the code below, if someone could take a glance and tell me if they see the error that would be great, if I need to provide more info please mention it and I will submit a more descriptive post SQLstmt=("SELECT DISTINCT Sale_Prodname.part_name, Sale_partnumber.*, SCompanies.Customer,SCompanies.customerID,Regions.Region, Regions.RegionID,"_	&amp; " Territories.Territories, Territories.ID, Territories.Abbreviation, " _	&amp; " E.First, E.Last, " &amp; Table &amp; ".*, SCompanies.Account, Sale_Prodname.Category, Distributor.Name AS DName, " _	&amp; " " &amp; SplitsTable &amp; ".TicketID AS Spl_TicketID, " &amp; SplitsTable &amp; ".Percentage AS Spl_Percentage, ES.First AS Spl_First, ES.Last AS Spl_Last, OEMCustomers.OEMName " _	&amp; " FROM Sale_Prodname INNER JOIN Sale_Partnumber ON Sale_Prodname.id = Sale_Partnumber.prodid"_	&amp; " INNER JOIN " &amp; Table &amp; " ON Sale_Partnumber.ID = " &amp; Table &amp; ".ProductID"_	&amp; " INNER JOIN Territories ON " &amp; Table &amp; ".TerritoryID = Territories.ID"_	&amp; " INNER JOIN SCompanies ON SCompanies.CustomerID = " &amp; Table &amp; ".DivisionID"_	&amp; " INNER JOIN Regions ON Regions.RegionID = Territories.RegionID "_	&amp; " LEFT JOIN txhelpdesk.dbo.Engineers E ON E.EngineerID = " &amp; Table &amp; ".EngID "_  &amp; " LEFT JOIN OEMCustomers ON OEMCustomers.OEMID = SCompanies.OEMID " _	&amp; " LEFT JOIN Distributor ON Distributor.ID = " &amp; Table &amp; ".Distributor "_	&amp; " LEFT JOIN " &amp; SplitsTable &amp; " ON DesignWin.TicketID = " &amp; SplitsTable &amp; ".TicketID " _	&amp; " LEFT JOIN txhelpdesk.dbo.Engineers ES ON ES.EngineerID = " &amp; SplitsTable &amp; ".EngID " _	&amp; " " &amp; InnerJoinCond &amp; " " &amp; MyDate &amp; " " &amp; MyCondition &amp; " " &amp; MyStatus &amp; " " &amp; MyCustomer &amp; " " &amp; MyAccess &amp; " " &amp; RSM_Condition &amp; " " &amp; MyDistributor &amp; MyOEMCustomer &amp; MyTimeFrame &amp; MyTier &amp; MySptf &amp; " ORDER BY " &amp; Table &amp; ".TicketID" )	'response.write Disposition &amp; ""	'response.write SQLStmt &amp; ""	'response.write AccessLevel &amp; ""		if Len(SavedSearch) &amp;gt; 0 then		set rs = conntemp.execute("SELECT SQLStmt, DateEntered FROM SavedSearch WHERE ID=" &amp; SavedSearch)		SQLStmt = rs(0)		SavedDate = rs(1)		SQLStmt = Replace(SQLStmt, SavedDate, Date)	end if		session("SaveSQL") = SQLstmt	session("InnerJoinCond") = InnerJoinCond		set rstemp = conntemp.execute(SQLstmt) &amp;lt;--SYNTAX ERROR at ")"	'if EngineerID=154 then response.write SQLStmt		IF rstemp.eof then		'if viewfrom=1 then			response.write "no matches found"			response.end		'end ifThanks in advance fro any help</description><pubDate>Wed, 08 Oct 2008 10:42:20 GMT</pubDate><dc:creator>michael.valentino</dc:creator></item></channel></rss>