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;

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • 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