Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix incorrect syntax near 'LOGIN' in SQL Server 2005

ALTER USER [myuser] WITH LOGIN =[myuser]

This query returns error in one of the SQL Server 2005 SP1 installation. Error is

Incorrect syntax near 'LOGIN'

like image 867
Rohit Avatar asked Nov 06 '22 12:11

Rohit


2 Answers

Several things

  • You do not need to use [] around the user name and login you want.
  • You seem to be trying to change the login to itself. That can't be right.

Try this:

ALTER USER myuser WITH LOGIN = myLOGIN

See the ALTER USER documentation on MSDN.

like image 187
Oded Avatar answered Nov 11 '22 04:11

Oded


The problem seems to be a bug in SQL Server 2005.

It is fixed at SP2. So, The the fix is to upgrade it to SP2 or above.

like image 31
Rohit Avatar answered Nov 11 '22 04:11

Rohit