Syntax error in SQL Server Function

I'm pretty new to SQL, especially creating SQL Funcitons. I getting a syntax error when I try to compile this function in the SSMS.

USE [JTSConversion]
GO
/****** Object:  UserDefinedFunction [dbo].[isALetter]   Script Date: 2/2/2018 2:30:26 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


Create FUNCTION [dbo].[isALetter] (@passedString varchar (1)) 
					RETURNS varchar(1)
AS
BEGIN
	-- Declare the return variable here
	DECLARE @Answer   varchar(1)
	DECLARE @strUCase varchar(1)

	set @Answer='N'    -- false

	Set @strUCase = upper(@passedString)

If @strUCase = ‘A’ Or @strUCase = ‘B’ Or @strUCase = ‘C’ Or @strUCase = ‘D’ Or @strUCase = ‘E’ Or 
   @strUCase = ‘F’ Or @strUCase = ‘G’ Or @strUCase = ‘H’ Or @strUCase = ‘I’ Or @strUCase = ‘J’ Or 
   @strUCase = ‘K’ Or @strUCase = ‘L’ Or @strUCase = ‘M’ Or @strUCase = ‘N’ Or @strUCase = ‘O’ Or 
   @strUCase = ‘P’ Or @strUCase = ‘Q’ Or @strUCase = ‘R’ Or @strUCase = ‘S’ Or @strUCase = ‘T’ Or 
   @strUCase = ‘U’ Or @strUCase = ‘V’ Or @strUCase = ‘W’ Or @strUCase = ‘X’ Or @strUCase = ‘Y’ Or 
   @strUCase = ‘Z’ 
    set @Answer='Y'

	return @Answer

END

Open in new window


The error is:
Msg 102, Level 15, State 1, Procedure isALetter, Line 22
Incorrect syntax near '‘'.

Line 22 is
If @strUCase = ‘A’ Or @strUCase = ‘B’ Or @strUCase = ‘C’ Or @strUCase = ‘D’ Or @strUCase = ‘E’ Or

I don't see it.  Can anyone spot the syntax error?
LVL 1
mlcktmguyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott PletcherSenior DBACommented:
Don't see the syntax error off hand, but you could use a lot less code to get the result:


CREATE FUNCTION [dbo].[isALetter] (@passedString varchar (1))
                              RETURNS varchar(1)
AS
BEGIN
RETURN (
    SELECT CASE WHEN UPPER(@passedString) LIKE '[A-Z]'
        THEN 'Y' ELSE 'N' END AS answer
)
END
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Garfield SamuelsProject ManagerCommented:
It seems to have an issue with your closing quote mark.  Try replacing them with regular quotes or the same ones you use for opening the quotes.
0
ste5anSenior DeveloperCommented:
Only the single quote ' is allowed as text delimiter. Not other apostroph symboles like ´`.
0
mlcktmguyAuthor Commented:
Wow, so much to learn.  Thanks for the much better approach.

Not sure what the original syntax error was but all of the text delimiters were already single quotes.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.