?
Solved

Copy records into a a table from the same table changing only one value

Posted on 2014-08-20
3
Medium Priority
?
162 Views
Last Modified: 2014-08-20
I have a table that has 6 fields , here is the query:

insert into [GSDR].[d2l].[d2l_reporting_SchoolPopulation]('2014-08-11',
      [Schoolcode],
      [School],
     [Cluster],
     [StudentCount],
      [IntructorCount])
     
 Select
        [Schoolcode],
      [School],
      [Cluster],
      [StudentCount]
       [IntructorCount]
 from [GSDR].[d2l].[d2l_reporting_SchoolPopulation]

I want to put in a population date of 2014-08, but basically copy all the other values.

here is my table

PopulationDate      Schoolcode       School                                             Cluster      StudentCount          IntructorCount
8/18/2014                978           ALCOVA ELEMENTARY SCHOOL             DACULA                    1133      71
8/18/2014                155            ALFORD ELEMENTARY SCHOOL       BERKMAR                   1021      62

This is want I want

PopulationDate      Schoolcode       School                                             Cluster      StudentCount          IntructorCount
8/18/2014                978           ALCOVA ELEMENTARY SCHOOL             DACULA                    1133      71
8/18/2014                155            ALFORD ELEMENTARY SCHOOL       BERKMAR                   1021      62
8/11/2014         978           ALCOVA ELEMENTARY SCHOOL             DACULA                    1133      71
8/11/2014                155            ALFORD ELEMENTARY SCHOOL       BERKMAR                   1021      62
0
Comment
Question by:Butterfly2
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
Deepak Subburajan earned 2000 total points
ID: 40272975
INSERT INTO [GSDR].[d2l].[d2l_reporting_SchoolPopulation]
SELECT
   ('2014-08-11',
   [Schoolcode],
   [School],
   [Cluster],
   [StudentCount],
   [IntructorCount])
FROM
   [GSDR].[d2l].[d2l_reporting_SchoolPopulation]

Open in new window

0
 

Author Comment

by:Butterfly2
ID: 40273099
i am geting a syntax error on on the comma after the  '2014-08-11'.

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ','.
0
 

Author Comment

by:Butterfly2
ID: 40273102
disregard, i removed the parenthesis and it works, thanks.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question