loads of useful information, examples and tutorials pertaining to web development utilizing asp.net, c#, vb, css, xhtml, javascript, sql, xml, ajax and everything else...

 



Advertise Here
C-Sharpener.com - Programming is Easy!  Learn Asp.Net & C# in just days, Guaranteed!

Incorrect syntax near 'something' in SQL 2005 while doing a 'CREATE USER' or 'CREATE LOGIN'

by naspinski 10/23/2008 7:03:00 AM

Annoying little problem and the simple fix

I was entering the following into my SQL Server Management Express window:
CREATE LOGIN 160thUser
  WITH PASSWORD = 'some_password';
USE name_of_db_to_use;
CREATE USER 160thUser FOR LOGIN 160thUser;

And I kept getting the error:
Incorrect syntax near '160'

Now I often use the same LOGIN and USER, so that was not the problem. What I found it out to be is that SQL 2005 does not allow LOGIN and USER obejcts to start with a number... sooo I just flipped them around to:
CREATE LOGIN User160th
  WITH PASSWORD = 'some_password';
USE name_of_db_to_use;
CREATE USER User160th FOR LOGIN User160th;

And everything worked.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

sql

Related posts


Comments are closed