title: Max database name length in SQL Server
body: <p>I am trying to do some UI validation on a database name. I was told from different places that the SQL Server database name is stored as <a href="http://msdn.microsoft.com/en-us/library/ms191240.aspx" rel="noreferrer">sysname</a> inside SQL Server. I also verified that by checking the <a href="http://msdn.microsoft.com/en-us/library/ms178534.aspx" rel="noreferrer">sys.Databases</a>.</p>
  
  <p>So, I make my textbox in the UI to have maxlength 128 characters long.  This is the max length of <code>sysname</code> type.</p>
  
  <p>However, I found that in my SQL Server 2005 Express edition, if I enter a database name with 128 characters long, it always complains </p>
  
  <blockquote>
    <p>Could not create default log file because the name was too long</p>
  </blockquote>
  
  <p>To make sure I can successfully create the database, I found that I need to set the max limit to 124 characters.</p>
  
  <p>My question now is whether 124 characters limit is true for all versions of SQL Server on all different Windows OS?</p>