TechTweets
Friday, 12 October 2012
How to find missing sequence number in a column of sql table?
Answer:-
UPDATE
a
SET
a
.
seq
=
b
.
seq
+
1
FROM
table1
AS
a
(
NOLOCK
)
INNER
JOIN
table1
AS
b
(
NOLOCK
)
LEFT
OUTER
JOIN
table1
AS
c
(
NOLOCK
)
ON
b
.
seq
+
1
=
c
.
seq
ON
a
.
seq
-
1
=
a
.
seq
+
1
WHERE
b
.
seq
IS
NULL
No comments:
Post a Comment
Newer Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment