Previously I had shown
- How to Create Temporary Table in SQL Server using # .
- Function that Splits string in SQL Server / Table Valued Function
- Create Relationships Between Tables OR Create Foreign Key Relationships
- Concatenate many rows into a single text string using SQL Server 2008
OutPut:
ID
|
Name
|
IsActive
|
1
|
Kiran
|
1
|
2
|
Ravi
|
1
|
3
|
Vara
|
1
|
4
|
Dinesh
|
1
|
5
|
Deleep
|
0
|
6
|
Phani
|
1
|
7
|
Shiva
|
1
|
8
|
shyam
|
0
|
Syntax :
declare @TableName as table
(
--Columns
)
Creating Table :
declare @Tbl as table
(
ID int identity(1,1),
Name nvarchar(max),
IsActive
bit
)
Inserting values into Temp Table
insert @Tbl (Name,IsActive)
values
('Kiran', 1),
('Ravi', 1),
('Vara', 1),
('Dinesh', 1),
('Deleep', 0),
('Phani', 1),
('Shiva', 1),
('shyam', 0)
select * from @Tbl
ID
|
Name
|
IsActive
|
1
|
Kiran
|
1
|
2
|
Ravi
|
1
|
3
|
Vara
|
1
|
4
|
Dinesh
|
1
|
5
|
Deleep
|
0
|
6
|
Phani
|
1
|
7
|
Shiva
|
1
|
8
|
shyam
|
0
|
No comments:
Post a Comment