Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Audit Example Simple
CREATE TABLE OrderHistory ( AuditID int NOT NULL, ProductID int NOT NULL, PriceOld decimal(18,2) NOT NULL, PriceNew decimal(18,2) NOT NULL, QuantityOld int NOT NULL, QuantityNew int NOT NULL ); INSERT dbo.OrderHistory VALUES (1, '111', 240, 300, 4, 5), (2, '222', 150, 225, 2, 3), (3, '333', 320, 128, 5, 2), (4, '444', 120, 240, 3, 6); SELECT H.ProductID, U.* FROM OrderHistory H CROSS APPLY( VALUES ('Price', Convert(nvarchar(max), PriceOld), Convert(nvarchar(max), PriceNew)), ('Quantity', Convert(nvarchar(max), QuantityOld), Convert(nvarchar(max), QuantityNew)) ) U (ColName, OldValue, NewValue)
run
|
edit
|
history
|
help
0
MindBoxTest
sql to search database objects' definitions for text
Turn column into string
Libros
Training1
Microsoft SQL Server T-SQL in 10 mn ~ Lesson 13 Subqueries samples...
Check Constraints
Crea, confirma y despliega tablas
Demo
add-empty-rows-after-certain-records-in-a-table