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