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. Index of item in subquery

Index of item in subquery

Scheduled Pinned Locked Moved Database
databasesql-server
3 Posts 2 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.
  • A Offline
    A Offline
    Addabis
    wrote on last edited by
    #1

    Hello, I need to delete for instance tenth item from table returned by subquery in MSSQL. So the best solution is to have row with some index. I guess there is some "function" for this. I mean something like this :) DELETE FROM (       SELECT SomeFunction AS 'index'       FROM table       WHERE conditions       ) t WHERE t.index = 10 Thanks Daniel Balas - Student

    A 1 Reply Last reply
    0
    • A Addabis

      Hello, I need to delete for instance tenth item from table returned by subquery in MSSQL. So the best solution is to have row with some index. I guess there is some "function" for this. I mean something like this :) DELETE FROM (       SELECT SomeFunction AS 'index'       FROM table       WHERE conditions       ) t WHERE t.index = 10 Thanks Daniel Balas - Student

      A Offline
      A Offline
      Arjan Einbu
      wrote on last edited by
      #2

      There is no T-SQL functionality that takes care of that. It would be impractical, since MSSQL (and others) return rows in "random order". You'l need to put on an index to be sure that it is deterministic. However, you can probably fake the desired functionality, by using a subquery/join in your delete statement...

      A 1 Reply Last reply
      0
      • A Arjan Einbu

        There is no T-SQL functionality that takes care of that. It would be impractical, since MSSQL (and others) return rows in "random order". You'l need to put on an index to be sure that it is deterministic. However, you can probably fake the desired functionality, by using a subquery/join in your delete statement...

        A Offline
        A Offline
        Addabis
        wrote on last edited by
        #3

        Hmm... thanx :) Daniel Balas - Student

        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