timestamp manupulation

Vineet S 145 Reputation points
2024-02-26T04:40:10.3066667+00:00

Hey, here is the table & it contains timestamp at the end. check the output

create table customer (CustomerName char(22), ContactName char(22), Address char(22), City char(22)
, PostalCode char(22), Country char(22),time DATETIME DEFAULT GETDATE())
INSERT INTO customer (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');
INSERT INTO customer (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal1', 'Tom B. Erichsen1', 'Skagen 211', 'Stavanger1', '4001', 'Norway1');
INSERT INTO customer (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal2', 'Tom B. Erichsen2', 'Skagen 212', 'Stavanger2', '4002', 'Norway2');
INSERT INTO customer (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal2', 'Tom B. Erichsen2', 'Skagen 212', 'Stavanger2', '4002', 'Norway2');

for row 2nd row , it should take previous timestamp +1 second for 3rd row, it should take next timestamp -1 second and it should keep happen when more records added User's image

desired: User's image

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,732 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,454 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,244 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 101K Reputation points MVP
    2024-02-28T22:47:05.8133333+00:00

    You can consider 3 things top row 2nf row, last row

    I'm sorry that does not tell me anything. What defines a "top row"?

    Keep in mind that tables are unordered objects. You may see an order when run a query, but that order is just accidental, unless there is something in the data that defines the order.

    And if there is nothing that defines the order, the answer is simple: it can't be done.