Problem with creating views

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sig Dock

    Problem with creating views

    Hi NG,

    I'm trying to run the following script as part of a larger scriptfile
    using isql:

    USE MYDB
    GO
    CREATE VIEW AGENCYSEARCH_mw b
    AS
    SELECT
    Id,
    SaveId,
    Checked,
    SessionId,
    substring(conve rt(char(26),Ins ertedDate,109), 1,20) +
    substring(conve rt(char(26),Ins ertedDate,109), 25,26)"Inserted Date",
    Name,
    key,
    sortorder,
    initname
    FROM MYDB.dbo.AGENCY SEARCH
    GO

    This results in an error:
    Msg 156, Level 15, State 1, Server Myserver, Procudere
    AGENCYSEARCH_mw b

    Incorrect syntax near keyword 'key'

    OK, so my guess is that 'key' is a reserved word and cannot be used in
    this context. But the column in this table is named 'key' so how can I
    create my view?
    Probably a basic problem for all the cracks over here but I'm just a
    simple Oracle DBA :-))))

    t.i.a.
  • nib

    #2
    Re: Problem with creating views

    Sig Dock wrote:[color=blue]
    > Hi NG,
    >
    > I'm trying to run the following script as part of a larger scriptfile
    > using isql:
    >
    > USE MYDB
    > GO
    > CREATE VIEW AGENCYSEARCH_mw b
    > AS
    > SELECT
    > Id,
    > SaveId,
    > Checked,
    > SessionId,
    > substring(conve rt(char(26),Ins ertedDate,109), 1,20) +
    > substring(conve rt(char(26),Ins ertedDate,109), 25,26)"Inserted Date",
    > Name,
    > key,
    > sortorder,
    > initname
    > FROM MYDB.dbo.AGENCY SEARCH
    > GO
    >
    > This results in an error:
    > Msg 156, Level 15, State 1, Server Myserver, Procudere
    > AGENCYSEARCH_mw b
    >
    > Incorrect syntax near keyword 'key'
    >
    > OK, so my guess is that 'key' is a reserved word and cannot be used in
    > this context. But the column in this table is named 'key' so how can I
    > create my view?
    > Probably a basic problem for all the cracks over here but I'm just a
    > simple Oracle DBA :-))))
    >
    > t.i.a.[/color]

    Use [] around the key column: [key].

    Zach

    Comment

    Working...