JoseAyeras
JoseAyeras

Reputation: 105

SQL - What clauses do ESCAPE characters work in?

I'm trying to make an SQL view where some columns would have special characters in them.

    #Hours  EmployeeID
    3       12D
    4       E44

I tried to use something like this...

CREATE VIEW rollCall AS
    SELECT (hourStart - hourEnd) AS ##Hours ESCAPE '#'
        , employeeID
    FROM Employee;

SELECT * FROM rollCall;

But for some reason I'm getting an error that said it expected a right parenthesis when AS came up. I'm confused about what to do here.

Upvotes: 0

Views: 25

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269633

I strongly advise you against doing this. But you need to escape the name:

CREATE VIEW rollCall AS
    SELECT (hourStart - hourEnd) AS "##Hours", 
           employeeID
    FROM Employee;

I only associate ESCAPE with LIKE, although it is perhaps used in some other clauses.

Upvotes: 1

Related Questions