I have the following sql code. Is it guaranteed that MyTable is going to be sorted by MyTable.data? Basically the question is - if I am inserting multiple rows with one INSERT statement, can other connection get in the middle of my insertion and insert something else in between my rows?
CREATE TABLE MyTable(
id bigint IDENTITY(1,1) NOT NULL,
data uniqueidentifier NOT NULL,
CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED (id ASC)
)
DECLARE @data uniqueidentifier
SET @data = NEWID()
WITH Dummy AS
(
SELECT @data as data, 1 as n
UNION ALL
SELECT @data, n + 1
FROM Dummy
WHERE n < 100
)
INSERT INTO MyTable(data)
SELECT data FROM Dummy
Thanks.