Reference > Functions > System
NewId
- 2005
- 2008
- 2012
- 2014
- 2016
- 2017
- 2019
- 2022
- 2005, 2008, 2012, 2014, 2016, 2017, 2019, 2022
NewId System Function
Use the NewId
function to return the server's current timestamp as a DateTime
value.
Microsoft SQL Server does not require a FROM clause to execute the NewId
function, but dbExpression requires a FROM clause to execute any query. For this function to execute on it's own, a "dummy" FROM clause must be provided.
Syntax
db.fx.NewId()
Arguments
(none)
Returns
Guid
Examples
Select Statement
Select a new id.
Guid id = db.SelectOne(
db.fx.NewId()
)
.From(dbo.Purchase) // <- "dummy" from clause
.Execute();