1️⃣ Current Date & Time
GETDATE() -- current date & time
CURRENT_TIMESTAMP -- same as GETDATE()
SYSDATETIME() -- higher precision
GETUTCDATE() -- UTC date & time.
✅ Use GETDATE() when:
-
You only need date & time
-
Precision is not critical
-
Legacy systems or existing
DATETIMEcolumnsTypical ETL load timestamps
✅ Use SYSDATETIME() when:
-
You need high precision timestamps
-
Logging, auditing, CDC, or incremental loads
-
Using
DATETIME2columns (recommended)
2️⃣ Extract Parts of Date
No comments:
Post a Comment