USE base_de_datos
DECLARE @minID INT=0
SELECT @minID = MIN(id_tabla) FROM tabla
DECLARE @maxID INT=0
SELECT @maxID = MAX(id_tabla) FROM tabla
WHILE @minID <= @maxID
BEGIN
IF EXISTS(SELECT * FROM tabla WHERE id_tabla=@minID)
PRINT 'exists ' + CAST(@minID AS VARCHAR)
ELSE
PRINT 'no exists ' + CAST(@minID AS VARCHAR)
SET @minID = @minID + 1
END
No hay comentarios.:
Publicar un comentario