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
 General SQL Server Forums
 New to SQL Server Programming
 Error With SQL Query

Author  Topic 

rds207
Posting Yak Master

198 Posts

Posted - 2010-05-24 : 20:34:35
Could you please let me why i am getting this error ?for the below code......

Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ','.
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near ','.
Msg 102, Level 15, State 1, Line 17
Incorrect syntax near ','.




SELECT     cm.*
FROM CRMMetrics AS cm INNER JOIN
BatchRecords AS br ON cm.ApplicationJobID = br.JobName
WHERE cm.Project = 'BMongr' AND cm.Type = 'Build' AND br.TerminationUser IS NULL AND br.EndTime IS NOT NULL), BuildRootsChildrenDuration AS
(SELECT br.ID AS ParentID, SUM(cm.NumSeconds) AS Duration
FROM CRMMetrics AS cm INNER JOIN
BuildRoots AS br ON cm.ParentID = br.ID
GROUP BY br.ID), BuildRootsLeftover AS
(SELECT br.ID AS ID, br.NumSeconds - cd.Duration AS LeftoverDuration, cd.Duration AS ChildrenDuration
FROM BuildRootsChildrenDuration AS cd INNER JOIN
BuildRoots AS br ON (cd.ParentID = br.ID)), BuildOverheads AS
(SELECT cm.ApplicationID AS ApplicationID, cm.ApplicationJobID AS ApplicationJobID, 'Other' AS Type, NULL AS StartTime,
LeftoverDuration AS NumSeconds
FROM CRMMetrics AS cm INNER JOIN
BuildRootsLeftover AS le ON cm.ID = le.ID)
SELECT ApplicationID AS BuildID, ApplicationJobID AS Jobname, Type AS Action, StartTime AS StartTime, NumSeconds AS Duration
FROM BuildOverheads
UNION
SELECT br.ApplicationID AS BuildID, br.ApplicationJobID AS Jobname, cm.Type AS Action, DATEADD(SECOND, cm.StartTime, '1970-01-01') AS StartTime,
cm.NumSeconds AS Duration
FROM CRMMetrics AS cm INNER JOIN
BuildRoots AS br ON (cm.ParentID = br.ID OR
cm.ID = br.ID)

sql-programmers
Posting Yak Master

190 Posts

Posted - 2010-05-24 : 23:46:44
Send me the table structure or could you explain the purpose of using comma sepeartor in where condtion.

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

rds207
Posting Yak Master

198 Posts

Posted - 2010-05-25 : 00:00:51
I am just trying to understand the syntax of a view(someone created) , BatchRecords and CRMMETRICS are the table we have , when i select the data from the view i get it , but when i just copy the syntax and execute it , i get an error...........

I am unable to understand how a view can be generated from a query with syntax error...

quote:
Originally posted by sql-programmers

Send me the table structure or could you explain the purpose of using comma sepeartor in where condtion.

SQL Server Programmers and Consultants
http://www.sql-programmers.com/

Go to Top of Page

zstarsales04
Starting Member

20 Posts

Posted - 2010-05-25 : 02:13:14
spam removed
Go to Top of Page
   

- Advertisement -