Sometimes the simplest of t-sql approaches are often overlooked. Once such instance I came across recently, was a developer trying to insert default values in a SQL Server Table. Here’s a simple way to insert Default Values in a SQL Server table
CREATE TABLE #Employees
(
ID int Identity(1,1) PRIMARY KEY,
EName varchar(50),
Designation varchar(50),
ManagerID int NULL
)
INSERT INTO #Employees DEFAULT VALUES;
SELECT * FROM #Employees
Observe how the DEFAULT VALUES option of the INSERT statement is used to add rows without supplying explicit values. Simple!
OUTPUT
No comments:
Post a Comment