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
 Converting Access SQL to SQL Server

Author  Topic 

nickelcell
Starting Member

3 Posts

Posted - 2010-10-18 : 15:13:31
Hello.

I am new to SQL server and trying to convert it from an Access SQL query and not having much luck with the cheat sheet. The query I am trying to convert is as follows:
Access SQL:
SELECT [IOP Pend Inst 2PM].[Lead/Opp ID #], [IOP Pend Inst 2PM].LOB, [IOP Pend Inst 2PM].[Lead Owner], [IOP Pend Inst 2PM].[Owner Scope], [IOP Pend Inst 2PM].Task, [IOP Pend Inst 2PM].Status, [IOP Pend Inst 2PM].[Account Number], [IOP Pend Inst 2PM].Account, [IOP Pend Inst 2PM].[Account Scope], [IOP Pend Inst 2PM].Site, [IOP Pend Inst 2PM].Address, [IOP Pend Inst 2PM].Address2, [IOP Pend Inst 2PM].City, [IOP Pend Inst 2PM].State, [IOP Pend Inst 2PM].Zip, [IOP Pend Inst 2PM].Division, [IOP Pend Inst 2PM].System, [IOP Pend Inst 2PM].Created, [IOP Pend Inst 2PM].[Due Date], [IOP Pend Inst 2PM].Scheduled, [IOP Pend Inst 2PM].Priority, [IOP Pend Inst 2PM].[Task Owner], [IOP Pend Inst 2PM].[Task Notes]
FROM [10-2 Reps] INNER JOIN [IOP Pend Inst 2PM] ON [10-2 Reps].[Rep Name] = [IOP Pend Inst 2PM].[Lead Owner]
WHERE ((([IOP Pend Inst 2PM].[Lead Owner]) Not In ('Nicole Hearne'). Can anyone assist me on what I am going wrong? Thanks in advance.

Nicole Lindsey

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-10-18 : 15:23:17
Somehow the NOT IN got changed to <>, just change it back to NOT IN.
Go to Top of Page

nickelcell
Starting Member

3 Posts

Posted - 2010-10-18 : 15:53:02
Thank you robvolk but it still gives me a syntax error message.

Nicole Lindsey
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-10-18 : 16:50:15
What's the exact error?
Go to Top of Page

nickelcell
Starting Member

3 Posts

Posted - 2010-10-18 : 17:01:41
Syntax error (missing operator)in query '[IOP Pend Inst 2PM].[Lead Owner] Not in(‘James Mead’,’Carl Dilores’,’Luann Brocco’,’Gabe Penafiel-WB’,’Kim Floodman-NB’,’Kenneth Higgins’,’Jennifer Bayer’,’David Knox’,’Kim Floodman’,’Lisa Geraghty’,’Michael Uryga’,’Brook Midgley’,’Gabe Penafiel’,’Michell".

Nicole Lindsey
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-10-18 : 17:23:08
Copy and paste this:
SELECT [IOP Pend Inst 2PM].[Lead/Opp ID #],
[IOP Pend Inst 2PM].LOB,
[IOP Pend Inst 2PM].[Lead Owner],
[IOP Pend Inst 2PM].[Owner Scope],
[IOP Pend Inst 2PM].Task,
[IOP Pend Inst 2PM].Status,
[IOP Pend Inst 2PM].[Account Number],
[IOP Pend Inst 2PM].Account,
[IOP Pend Inst 2PM].[Account Scope],
[IOP Pend Inst 2PM].Site,
[IOP Pend Inst 2PM].Address,
[IOP Pend Inst 2PM].Address2,
[IOP Pend Inst 2PM].City,
[IOP Pend Inst 2PM].State,
[IOP Pend Inst 2PM].Zip,
[IOP Pend Inst 2PM].Division,
[IOP Pend Inst 2PM].System,
[IOP Pend Inst 2PM].Created,
[IOP Pend Inst 2PM].[Due Date],
[IOP Pend Inst 2PM].Scheduled,
[IOP Pend Inst 2PM].Priority,
[IOP Pend Inst 2PM].[Task Owner],
[IOP Pend Inst 2PM].[Task Notes]
FROM [10-2 Reps] INNER JOIN [IOP Pend Inst 2PM] ON [10-2 Reps].[Rep Name] = [IOP Pend Inst 2PM].[Lead Owner]
WHERE [IOP Pend Inst 2PM].[Lead Owner] NOT IN('James Mead','Carl Dilores','Luann Brocco','Gabe Penafiel-WB',
'Kim Floodman-NB','Kenneth Higgins','Jennifer Bayer','David Knox','Kim Floodman','Lisa Geraghty','Michael Uryga',
'Brook Midgley','Gabe Penafiel','Michelle Brochet','Robert Carlsen','Kathi Bunyer','Sherman Crancer','Jaydee Banasky',
'Britney Murphy','Jamie Gersten','Wendy Frayne','Rick Shoulberg','Marcella Jones','Nancy Fuller','Maureen Boldurian',
'Bryan Upcraft','Steven Pinheiro','Amanda Yniguez','Ana Beltran','Brian Shaffer','David Nikmorad','Deven Nicholson',
'Donna Lundquist','Fred Taylor','Gene Wang','Jeremy Harden','Jesse Aflague','Joseph Pulizzi','Kevin Laris','Kevin Tran',
'Lisa Oliva','Mario Rodriguez','Mark Babel','Michael Contreras','Michael Lacey','Raquel Ruiz','Russell Sabal','Sami Azar',
'Miranda Tafreshinejad','Ariel Farr','Maria Guillory','Monica Wilkonson','Terrie Pearson','Samuel Peinado','David Martinez',
'Cameron Allison','Eric Morton')
It passes a syntax check for me in Management Studio.

Looks like you copied this from Word or some other product that put in "smart" quotes, use Notepad or SSMS instead.
Go to Top of Page
   

- Advertisement -