Help needed for Update Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • britania
    New Member
    • Mar 2008
    • 5

    Help needed for Update Query

    Im looking for some help by a MSSQL 2000 expert.

    I need to update dbo.prop_main with information from another table dbo.properties

    Basically where prop_propertyID = Prop_ID in both tables

    add the northings_COORD and eastings_COORD information from dbo.properties to the northings and eastings from dbo.prop_main

    Can anyone help me construct this?

    dbo.prop_main
    prop_propertyID
    northings
    eastings


    dbo.properties
    Prop_ID
    northings_COORD
    eastings_COORD
  • deepuv04
    Recognized Expert New Member
    • Nov 2007
    • 227

    #2
    Originally posted by britania
    Im looking for some help by a MSSQL 2000 expert.

    I need to update dbo.prop_main with information from another table dbo.properties

    Basically where prop_propertyID = Prop_ID in both tables

    add the northings_COORD and eastings_COORD information from dbo.properties to the northings and eastings from dbo.prop_main

    Can anyone help me construct this?

    dbo.prop_main
    prop_propertyID
    northings
    eastings


    dbo.properties
    Prop_ID
    northings_COORD
    eastings_COORD

    Is this the query you are looking for...

    [code=sql]
    UPDATE Prop_Main
    SET northings = northings + properties.nort hings_COORD,
    eastings = eastings + properties.east ings_COORD
    FROM Prop_Main INNER JOIN
    properties ON properties.Prop _ID = Prop_Main.prop_ propertyID
    [/code]

    Comment

    • britania
      New Member
      • Mar 2008
      • 5

      #3
      Thanks for the reply :) it looks promising.

      Will that query add the northings_COORD and eastings_COORD from the Properties table to the Prop_Main northings and eastings table columns?

      The query resolves on Query Analyzer, so good so far, I have to work with live data on this one, so double checking.

      so basically anywhere the ids = in both tables add the coords from properties to prop_main

      Comment

      • deepuv04
        Recognized Expert New Member
        • Nov 2007
        • 227

        #4
        Originally posted by britania
        Thanks for the reply :) it looks promising.

        Will that query add the northings_COORD and eastings_COORD from the Properties table to the Prop_Main northings and eastings table columns?

        The query resolves on Query Analyzer, so good so far, I have to work with live data on this one, so double checking.

        so basically anywhere the ids = in both tables add the coords from properties to prop_main
        hi,
        That will work.. try using some test data or
        First select the live data for testing using select statement and if you feel comfortable with that you can implement on live data

        thanks

        Comment

        • britania
          New Member
          • Mar 2008
          • 5

          #5
          many thanks - i am going to set a test environment up...i'll let you know if im smiling!

          thanks again

          Comment

          • britania
            New Member
            • Mar 2008
            • 5

            #6
            Ive created a test site.

            when i run the query i get this error?:

            Server: Msg 446, Level 16, State 9, Line 1
            Cannot resolve collation conflict for equal to operation.

            Comment

            • britania
              New Member
              • Mar 2008
              • 5

              #7
              ive solved it, it needed COLLATE database_defaul t adding to the end off the query as it seems to get in a muddle which database to look at:

              SHGproperties ON SHGProperties.P rop_ID = Prop_Main.prop_ propertyID COLLATE database_defaul t

              Comment

              Working...