Unable to create USER with T-SQL

  • Hello Community,

    Can someone explain why I'm getting the error

    Incorrect syntax near '-'

    When I run the followng sql code:

    CREATE USER DT-SERVICES-TEST WITHOUT LOGIN;

    My guess is because of the hypen '-'

    If that is the case, can someone let me know how to add the code with the hypen?

    Thanks

     

     

  • Use square brackets:

    CREATE USER [DT-SERVICES-TEST] WITHOUT LOGIN;

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • You are correct, the problem is the hyphen. You will need to delimit identify the object name: [DT-SERVICES-TEST].

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Got Yer.

    Thanks

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply