title: New to SQL - Why is my Insert into trying to insert NULL into primary key?
body: <p>What I want to do is insert a range of dates into multiple rows for customerID=1. I have and insert for dbo.Customer(Dates), specifying my that I want to insert a record into the Dates column for my Customer table, right? I am getting error: </p>
  
  <blockquote>
    <p><strong>Cannot insert the value NULL into column 'CustomerId', table 'dbo.Customers'</strong></p>
  </blockquote>
  
  <p>Sorry if I am way off track here. I have looked at similar threads to find out what I am missing, but I'm not piecing this together. I am thinking it wants to overwrite the existing customer ID as NULL, but I am unsure why exactly since I'm specifying dbo.Customer(Dates) and not the existing customerID for that record.</p>
  
  <pre><code>declare @date_Start datetime = '03/01/2011'
  declare @date_End datetime = '10/30/2011'
  declare @date datetime = @date_Start
  
  while @date &lt;= @date_End
  begin
  insert into dbo.Customer(Dates) select @date
  if DATEPART(dd,@date) = 0
      set @date = DATEADD(dd, -1, DATEADD(mm,1,@date))
  else
      set @date = DATEADD(dd,1,@date)
  end
  
  select * from dbo.Customer
  </code></pre>