Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Question on SQL syntax

Question on SQL syntax

Scheduled Pinned Locked Moved Database
questiondatabase
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leckey 0
    wrote on last edited by
    #1

    I am trying to move some records from table A to table B. This is what I have thus far: declare @PartID varchar(50), @SectionNumber varchar(50), @TopWidth float, @BottomWidth float, @boltDiameter float, @pickOrder int Select * from SSVLStandardBracingDesign set @PartID = SSVLSTandardBracingDesign.PartID set @SectionNumber = SSVLStandardBracingDesign.SectionNumber set @TopWidth = SSVLStandardBracingDesign.TopWidth set @BottomWidth = SSVLStandardBracingDesign.BottomWidth set @boltDiameter = SSVLStandardBracingDesign.BracingBoltDiameter set @pickOrder = SSVLStandardBracingDesign.PickOrder insert into BracingKits (PartID, SectionNumber, topWidth, bottomWidth, boltDiameter, pickOrder, S3TL29, S3TLVL, S3TLUL, S3TLMD, S3TLHD, S3TLVH, S3TLUH,S3R, S4TL,S4A, [1200TLWD],[1800TLWD], [1800SRWD], [2400SRWD],[3600SRWD] , [4400SRWD]) VALUES (@PartID, @SectionNumber, @TopWidth, @BottomWidth, @boltDiameter, @PickOrder, 0,1,0,0,0,0,0,0,0,0, 0, 0,0,0,0,0) I need to set my variables to values from the table. I tried using commas but that didn't work, and my multiple set statements do not work. What is the correct syntax? Thanks!

    P E U 3 Replies Last reply
    0
    • L leckey 0

      I am trying to move some records from table A to table B. This is what I have thus far: declare @PartID varchar(50), @SectionNumber varchar(50), @TopWidth float, @BottomWidth float, @boltDiameter float, @pickOrder int Select * from SSVLStandardBracingDesign set @PartID = SSVLSTandardBracingDesign.PartID set @SectionNumber = SSVLStandardBracingDesign.SectionNumber set @TopWidth = SSVLStandardBracingDesign.TopWidth set @BottomWidth = SSVLStandardBracingDesign.BottomWidth set @boltDiameter = SSVLStandardBracingDesign.BracingBoltDiameter set @pickOrder = SSVLStandardBracingDesign.PickOrder insert into BracingKits (PartID, SectionNumber, topWidth, bottomWidth, boltDiameter, pickOrder, S3TL29, S3TLVL, S3TLUL, S3TLMD, S3TLHD, S3TLVH, S3TLUH,S3R, S4TL,S4A, [1200TLWD],[1800TLWD], [1800SRWD], [2400SRWD],[3600SRWD] , [4400SRWD]) VALUES (@PartID, @SectionNumber, @TopWidth, @BottomWidth, @boltDiameter, @PickOrder, 0,1,0,0,0,0,0,0,0,0, 0, 0,0,0,0,0) I need to set my variables to values from the table. I tried using commas but that didn't work, and my multiple set statements do not work. What is the correct syntax? Thanks!

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      You are missing a select statement. Take a peek at the provided link :) http://www.databasejournal.com/features/mssql/article.php/3507171[^] PJC


      I'd like to help but I don't feel like Googling it for you.

      L 1 Reply Last reply
      0
      • L leckey 0

        I am trying to move some records from table A to table B. This is what I have thus far: declare @PartID varchar(50), @SectionNumber varchar(50), @TopWidth float, @BottomWidth float, @boltDiameter float, @pickOrder int Select * from SSVLStandardBracingDesign set @PartID = SSVLSTandardBracingDesign.PartID set @SectionNumber = SSVLStandardBracingDesign.SectionNumber set @TopWidth = SSVLStandardBracingDesign.TopWidth set @BottomWidth = SSVLStandardBracingDesign.BottomWidth set @boltDiameter = SSVLStandardBracingDesign.BracingBoltDiameter set @pickOrder = SSVLStandardBracingDesign.PickOrder insert into BracingKits (PartID, SectionNumber, topWidth, bottomWidth, boltDiameter, pickOrder, S3TL29, S3TLVL, S3TLUL, S3TLMD, S3TLHD, S3TLVH, S3TLUH,S3R, S4TL,S4A, [1200TLWD],[1800TLWD], [1800SRWD], [2400SRWD],[3600SRWD] , [4400SRWD]) VALUES (@PartID, @SectionNumber, @TopWidth, @BottomWidth, @boltDiameter, @PickOrder, 0,1,0,0,0,0,0,0,0,0, 0, 0,0,0,0,0) I need to set my variables to values from the table. I tried using commas but that didn't work, and my multiple set statements do not work. What is the correct syntax? Thanks!

        E Offline
        E Offline
        Eric Dahlvang
        wrote on last edited by
        #3

        INSERT INTO BracingKits SELECT PartID, SectionNumber, topWidth, bottomWidth, boltDiameter, pickOrder,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 from SSVLStandardBracingDesign

        --EricDV Sig--------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters

        1 Reply Last reply
        0
        • P Paul Conrad

          You are missing a select statement. Take a peek at the provided link :) http://www.databasejournal.com/features/mssql/article.php/3507171[^] PJC


          I'd like to help but I don't feel like Googling it for you.

          L Offline
          L Offline
          leckey 0
          wrote on last edited by
          #4

          Thank you for the link, that helped. I have another question though that it does not answer. I need to insert some 1's and 0's that are bit fields that don't come from the original table so they are not part of the select statement. This is what I have now: insert into BracingKits (PartID, SectionNumber, topWidth, bottomWidth, boltDiameter, pickOrder, **S3TL29, S3TLVL, S3TLUL, S3TLMD, S3TLHD, S3TLVH, S3TLUH,S3R, S4TL,S4A, [1200TLWD],[1800TLWD], [1800SRWD], [2400SRWD],[3600SRWD] , [4400SRWD])** SELECT PartID, SectionNumber, TopSread, BottomSpread, BracingBoltDiameter, PickOrder from SSVLSStandardBracingDesign But all those that are bold need to be the 1/0's. How can I inculde this as part of the statement?

          E J 2 Replies Last reply
          0
          • L leckey 0

            Thank you for the link, that helped. I have another question though that it does not answer. I need to insert some 1's and 0's that are bit fields that don't come from the original table so they are not part of the select statement. This is what I have now: insert into BracingKits (PartID, SectionNumber, topWidth, bottomWidth, boltDiameter, pickOrder, **S3TL29, S3TLVL, S3TLUL, S3TLMD, S3TLHD, S3TLVH, S3TLUH,S3R, S4TL,S4A, [1200TLWD],[1800TLWD], [1800SRWD], [2400SRWD],[3600SRWD] , [4400SRWD])** SELECT PartID, SectionNumber, TopSread, BottomSpread, BracingBoltDiameter, PickOrder from SSVLSStandardBracingDesign But all those that are bold need to be the 1/0's. How can I inculde this as part of the statement?

            E Offline
            E Offline
            Ennis Ray Lynch Jr
            wrote on last edited by
            #5

            look up CASE statements in SQL that should work.

            A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

            1 Reply Last reply
            0
            • L leckey 0

              Thank you for the link, that helped. I have another question though that it does not answer. I need to insert some 1's and 0's that are bit fields that don't come from the original table so they are not part of the select statement. This is what I have now: insert into BracingKits (PartID, SectionNumber, topWidth, bottomWidth, boltDiameter, pickOrder, **S3TL29, S3TLVL, S3TLUL, S3TLMD, S3TLHD, S3TLVH, S3TLUH,S3R, S4TL,S4A, [1200TLWD],[1800TLWD], [1800SRWD], [2400SRWD],[3600SRWD] , [4400SRWD])** SELECT PartID, SectionNumber, TopSread, BottomSpread, BracingBoltDiameter, PickOrder from SSVLSStandardBracingDesign But all those that are bold need to be the 1/0's. How can I inculde this as part of the statement?

              J Offline
              J Offline
              Jon Sagara
              wrote on last edited by
              #6

              Just code in literals: SELECT PartID, SectionNumber, TopSread, BottomSpread, BracingBoltDiameter, PickOrder, 0, 0, 0, 0, 1, 0, 0, 1, ... from SSVLSStandardBracingDesign -- modified at 16:07 Thursday 17th August, 2006

              Jon Sagara When I grow up, I'm changing my name to Joe Kickass! My Site | My Blog | My Articles

              1 Reply Last reply
              0
              • L leckey 0

                I am trying to move some records from table A to table B. This is what I have thus far: declare @PartID varchar(50), @SectionNumber varchar(50), @TopWidth float, @BottomWidth float, @boltDiameter float, @pickOrder int Select * from SSVLStandardBracingDesign set @PartID = SSVLSTandardBracingDesign.PartID set @SectionNumber = SSVLStandardBracingDesign.SectionNumber set @TopWidth = SSVLStandardBracingDesign.TopWidth set @BottomWidth = SSVLStandardBracingDesign.BottomWidth set @boltDiameter = SSVLStandardBracingDesign.BracingBoltDiameter set @pickOrder = SSVLStandardBracingDesign.PickOrder insert into BracingKits (PartID, SectionNumber, topWidth, bottomWidth, boltDiameter, pickOrder, S3TL29, S3TLVL, S3TLUL, S3TLMD, S3TLHD, S3TLVH, S3TLUH,S3R, S4TL,S4A, [1200TLWD],[1800TLWD], [1800SRWD], [2400SRWD],[3600SRWD] , [4400SRWD]) VALUES (@PartID, @SectionNumber, @TopWidth, @BottomWidth, @boltDiameter, @PickOrder, 0,1,0,0,0,0,0,0,0,0, 0, 0,0,0,0,0) I need to set my variables to values from the table. I tried using commas but that didn't work, and my multiple set statements do not work. What is the correct syntax? Thanks!

                U Offline
                U Offline
                unclepaul
                wrote on last edited by
                #7

                Select @PartID = SSVLSTandardBracingDesign.PartID, @SectionNumber = SSVLStandardBracingDesign.SectionNumber, @TopWidth = SSVLStandardBracingDesign.TopWidth, @BottomWidth = SSVLStandardBracingDesign.BottomWidth, @boltDiameter = SSVLStandardBracingDesign.BracingBoltDiameter, @pickOrder = SSVLStandardBracingDesign.PickOrder from SSVLStandardBracingDesign

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups