update query - Add a - after everthing in a specific field. Sql server 2008

  • I am trying to write the correct syntax for adding a dash to everything in a specific field.

    The query I came up with:

    update table1

    set field1 = '-' & [field1]

    from table1

    syntax works in access but not SQL SERVER 2008. I need the SQL 2008 syntax. Please help

    original data in field

    field1: 1 Result I need: -1

  • Hi

    use this below syntax.

    update table1

    set field1 = '-'+Field1

    --with where condition

    update table1

    set field1 = '-'+Field1

    where field2 =1 0

  • the field is an integer and will not update with a dash. Is there a conversion I have to do?

  • update table1

    set field1 = Field1 - Field1 * 2

    It should work some extent.

  • SampathKumarM (11/23/2013)


    update table1

    set field1 = Field1 - Field1 * 2

    It should work some extent.

    That seems the hard way to do

    update table1 set field1 = 0 - field1;

    (or even just = - field1).

    Tom

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply