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. SQL

SQL

Scheduled Pinned Locked Moved Database
databaseannouncement
4 Posts 4 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.
  • D Offline
    D Offline
    dev_rfid
    wrote on last edited by
    #1

    update command for interchanging to field values ex. f_name L_name -------------------------- a b c d by mistake f_name went to l_name and vise varsa:)

    R T M 3 Replies Last reply
    0
    • D dev_rfid

      update command for interchanging to field values ex. f_name L_name -------------------------- a b c d by mistake f_name went to l_name and vise varsa:)

      R Offline
      R Offline
      Ritesh1234
      wrote on last edited by
      #2

      Hi, Why don't u try with cursors...... e.g DECLARE authors CURSOR FOR SELECT au_id, f_name, l_name FROM authors OPEN authors FETCH NEXT FROM authors INTO @au_id, @au_fname, @au_lname WHILE @@FETCH_STATUS = 0 BEGIN Update author_master SET f_name = @au_lname, l_name = @au_fname WHERE au_id = @au_id FETCH NEXT FROM authors_cursor INTO @au_id, @au_fname, @au_lname END CLOSE authors DEALLOCATE authors GO I hope this will help u.... Regards, Ritesh

      1 Reply Last reply
      0
      • D dev_rfid

        update command for interchanging to field values ex. f_name L_name -------------------------- a b c d by mistake f_name went to l_name and vise varsa:)

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        ...and the question is ?


        TOXCCT >>> GEII power
        [toxcct][VisualCalc 2.20][VisualCalc 3.0]

        1 Reply Last reply
        0
        • D dev_rfid

          update command for interchanging to field values ex. f_name L_name -------------------------- a b c d by mistake f_name went to l_name and vise varsa:)

          M Offline
          M Offline
          miah alom
          wrote on last edited by
          #4

          Simply run the update command. Below is a sample. CREATE TABLE dbo.ctm ( id numeric(18,0) IDENTITY, col1 varchar(20) NULL, col2 varchar(20) NULL ) go INSERT INTO dbo.ctm ( col1, col2 ) VALUES ( 'aa', 'bb' ) INSERT INTO dbo.ctm ( col1, col2 ) VALUES ( 'cc', 'dd' ) SELECT T.id, T.col1, T.col2 FROM dbo.ctm T update ctm set col1 = col2, col2 = col1 SELECT T.id, T.col1, T.col2 FROM dbo.ctm T

          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