title: Insert date value yyyy-mm-dd hh:mm:ss into SQL Server
body: <p>I need to insert some records with date values. The format is <code>'2006-07-26 00:00:00.000'.</code> When I try the query I get the error </p>
  
  <blockquote>
    <p>Conversion failed when converting date and/or time from character string</p>
  </blockquote>
  
  <p>How do I format that to get it inserted?</p>
  
  <pre><code>INSERT [dbo].[NAMES] (
      [NAME_CODE]
      ,[NAME_ID]
      ,[NAME_CODE_ID]
      ,[PREVIOUS_ID]
      ,[GOVERNMENT_ID]
      ,[PREV_GOV_ID]
      ,[PREFIX]
      ,[FIRST_NAME]
      ,[MIDDLE_NAME]
      ,[LAST_NAME]
      ,[SUFFIX]
      ,[NICKNAME]
      ,[PREFERRED_ADD]
      ,[BIRTH_DATE]
      ,[BIRTH_CITY]
      ,[BIRTH_STATE]
      ,[BIRTH_ZIP_CODE]
      ,[BIRTH_COUNTRY]
      ,[BIRTH_COUNTY]
      ,[DECEASED_DATE]
      ,[DECEASED_FLAG]
      ,[RELEASE_INFO]
      ,[CREATE_DATE]
      ,[CREATE_TIME]
      ,[CREATE_OPID]
      ,[CREATE_TERMINAL]
      ,[REVISION_DATE]
      ,[REVISION_TIME]
      ,[REVISION_OPID]
      ,[REVISION_TERMINAL]
      ,[ABT_JOIN]
      ,[TAX_ID]
      ,[PersonId]
      ,[PrimaryPhoneId]
      ,[Last_Name_Prefix]
      ,[LegalName]
      )
  VALUES (
      N'P'
      ,2
      ,N'P000000002'
      ,N'NULL'
      ,363768306
      ,N'NULL'
      ,N'Dr.'
      ,N'Pever'
      ,N'G'
      ,N'Giper'
      ,N'NULL'
      ,N'NULL'
      ,N'PERM'
      ,N'NULL'
      ,N'NULL'
      ,N'NULL'
      ,N'NULL'
      ,N'NULL'
      ,N'NULL'
      ,N'NULL'
      ,N'N'
      ,N'NULL'
      ,N'2006-07-26 00:00:00.000'
      ,N'1900-01-01 08:39:02.000'
      ,N'SCT'
      ,1
      ,N'2014-06-27 00:00:00.000'
      ,N'1900-01-01 15:39:44.617'
      ,N'SSTULTS'
      ,1
      ,N'*'
      ,N'NULL'
      ,1
      ,N'NULL'
      ,N'NULL'
      ,N'NULL'
      ) GO
  </code></pre>