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 2005 Forums
 Transact-SQL (2005)
 Incorrect syntax near the keyword 'with'

Author  Topic 

nto
Starting Member

12 Posts

Posted - 2009-09-28 : 22:18:59
Hi Guys,

i have this Store Proc however it return me this error
"
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon"

however when i change @numberOfReports with a int number, example 25
everything is running smooth.
Do you guys have any idea how to fix this problem?

ALTER PROCEDURE [dbo].[proc_Search_Log]
(
@mobileID int,
@numberOfReports int
)
AS
BEGIN
SELECT
TOP @numberOfReports
L.mobileID AS 'Mobile ID',
L.RecordedDT AS 'Date Recorded',
L.NoSatellites AS 'Satellites',
L.GPSSpeed AS 'Speed',
L.GPSHeading AS 'Heading',
L.Latitude,
L.Longitude,
L.StatusID,
S.StatusID,
S.status,
S.Description
FROM
Log L with (nolock)
LEFT JOIN [Status] S ON L.StatusID = S.Status
WHERE
mobileID = @mobileID
ORDER BY
LogRecordID DESC
END

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-09-28 : 23:24:55
SELECT
TOP (@numberOfReports)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

nto
Starting Member

12 Posts

Posted - 2009-09-29 : 02:23:50
Thanks it work :)
Go to Top of Page
   

- Advertisement -