Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


"Incorrect syntax near 'AS'. Expecting ID, '(', or PRIMARY"


"Incorrect syntax near 'AS'. Expecting ID, '(', or PRIMARY"

Author
Message
rojas9198
rojas9198
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 4
I am getting the error above while trying to implement a Snapshot. Before the snapshot, I created three filegroups with their corresponding files as follows:

NAME / FILENAME
fg0103SALES; 'J:\AdventureWorks_FileGroups\FG0103SALES\0103SALES.ndf'
fg0406SALES; 'J:\AdventureWorks_FileGroups\FG0103SALES\0406SALES.ndf'
fg0708SALES; 'J:\AdventureWorks_FileGroups\FG0103SALES\0708SALES.ndf'

My code is as follows:

USE Master
GO
CREATE DATABASE AdventureWorks_snap021607 ON
(NAME = AdventureWorks_Data, FILENAME = 'C:\AdventureWorks_data_021607.ss' ),
(NAME = fg0103SALES , FILENAME = 'J:\AdventureWorks_FileGroups\FG0103SALES\0103SALES.ndf'),
(NAME = fg0406SALES , FILENAME = 'J:\AdventureWorks_FileGroups\FG0406SALES\0406SALES.ndf'),
(NAME = fg0708SALES , FILENAME = 'J:\AdventureWorks_FileGroups\FG0708SALES\0708SALES.ndf'),
AS SNAPSHOT OF AdventureWorks
GO

Please help.

Thanks,
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47198 Visits: 44367
There's a comma before the AS where it shouldn't be.

USE Master
GO
CREATE DATABASE AdventureWorks_snap021607 ON
(NAME = AdventureWorks_Data, FILENAME = 'C:\AdventureWorks_data_021607.ss' ),
(NAME = fg0103SALES , FILENAME = 'J:\AdventureWorks_FileGroups\FG0103SALES\0103SALES.ndf'),
(NAME = fg0406SALES , FILENAME = 'J:\AdventureWorks_FileGroups\FG0406SALES\0406SALES.ndf'),
(NAME = fg0708SALES , FILENAME = 'J:\AdventureWorks_FileGroups\FG0708SALES\0708SALES.ndf')
AS SNAPSHOT OF AdventureWorks
GO




Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


rojas9198
rojas9198
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 4
You got it! Thanks.
GOODS
GOODS
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 253
Hi guys I'm also getting the same error:This is my query please assist:
Select
a.ApplicantName
,a.ApplicationUniqueNumber
,a.MeetingDate as DateOfApproval
,a.ProjectSICDescription as Sector
,b.Description as Product
,a.Province
,a.Investment
,a.GrantAmount
,g.FIG
,dbo.fn_ProjectSize(c.TotalIncentive)as ProjectSize
,d.status
,dbo.fn_GetProjectJobsNew(e.id) as NewJobs
,dbo.fn_GetProjectJobsExisting(e.ID) as JobsExisting
,(f.BFemale +f.CFemale + f.DFemale +f.IFemale + f.OFemale + f.WFemale) AS NumberOfFemales
,(f.BMale + f.CMale + f.DMale + f.IMale + f.OMale + f.WMale) as NumberOfMale

from ApplicationApprovalsList a inner join
ProductDescriptionForApproval b on a.Id= b.ApplicationHeaderId inner join
ApplicationHeader c on c.Id = b.ApplicationHeaderId inner join
AppStatus d on d.id = c.Status inner join
Project e on e.ApplicationHeaderId = c.Id left join
ProjectEmployment f on f.ProjectId = e.Id left join
Budget g on g.ProjectId = e.Id join
( select sh.Description from ShareHolder sh)

WHERE (c.AcknowledgeDate BETWEEN CONVERT(DATETIME, '2012-07-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-09-30 00:00:00',
102))
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47198 Visits: 44367
You need an alias for the subquery in the from, and you need to finish the missing portion of the join clause.

p.s. Please post new questions in new threads in future. Thanks.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


GOODS
GOODS
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 253
Thanks will in future,I did finish the join and put in alias but I'm getting two errors:1 next to alias h I the following error "An expression of non-Boolean type specified in a context where a condition is expected:
2 next to the WHERE clause "Incorrect syntax near 'WHERE"
Select
a.ApplicantName
,a.ApplicationUniqueNumber
,a.MeetingDate as DateOfApproval
,a.ProjectSICDescription as Sector
,b.Description as Product
,a.Province
,a.Investment
,a.GrantAmount
,g.FIG
,dbo.fn_ProjectSize(c.TotalIncentive)as ProjectSize
,d.status
,dbo.fn_GetProjectJobsNew(e.id) as NewJobs
,dbo.fn_GetProjectJobsExisting(e.ID) as JobsExisting
,(f.BFemale +f.CFemale + f.DFemale +f.IFemale + f.OFemale + f.WFemale) AS NumberOfFemales
,(f.BMale + f.CMale + f.DMale + f.IMale + f.OMale + f.WMale) as NumberOfMale

from ApplicationApprovalsList a inner join
ProductDescriptionForApproval b on a.Id= b.ApplicationHeaderId inner join
ApplicationHeader c on c.Id = b.ApplicationHeaderId inner join
AppStatus d on d.id = c.Status inner join
Project e on e.ApplicationHeaderId = c.Id left join
ProjectEmployment f on f.ProjectId = e.Id left join
Budget g on g.ProjectId = e.Id left join

( select sh.Description from ShareHolder sh ) As h

WHERE (c.AcknowledgeDate BETWEEN CONVERT(DATETIME, '2012-07-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-09-30 00:00:00',
102))
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47198 Visits: 44367
You haven't finished the last join in the from clause.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


GOODS
GOODS
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 253
Thanks mil got it:-D..
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search