In this article I will explain with an example, how to insert value for Time Datatype in SQL Server.
1. Use the SQL Server 2008 Time Data Type and define its columns in Tables.
2. Understanding the precision in Time Data Type.
3. Get Current System Time.
4. How to insert Time Values using SQL Query into Tables.
In order to explain the concept practically I have created a Table named as Meetings which is used to reserve Meeting Room by various employees in the company
 
 
Table with Time Data Type Columns
Below is the SQL Script to create a table named as Meetings.
CREATE TABLE [dbo].[Meetings](
      [MeetingId] [int] IDENTITY(1,1) NOT NULL,
      [ReservedBy] [varchar](15) NOT NULL,
      [StartTime] [time](7) NOT NULL,
      [EndTime] [time](7) NOT NULL,
 CONSTRAINT [PK_Meetings] PRIMARY KEY CLUSTERED
(
      [MeetingId] ASC
)
) ON [PRIMARY]
 
GO

Insert value for Time Datatype in SQL Server example
 
The Precision in Time Data Type
Now you will notice the number 7 next to the time data type [time](7). It is used for setting the precision value. If not specified the default value is 7.
SELECT 1, CAST(CONVERT(TIME(0),GETDATE()) AS VARCHAR(15))
UNION ALL
SELECT 2, CAST(CONVERT(TIME(1),GETDATE()) AS VARCHAR(15))
UNION ALL
SELECT 3, CAST(CONVERT(TIME(2),GETDATE()) AS VARCHAR(15))
UNION ALL
SELECT 4, CAST(CONVERT(TIME(3),GETDATE()) AS VARCHAR(15))
UNION ALL
SELECT 5, CAST(CONVERT(TIME(4),GETDATE()) AS VARCHAR(15))
UNION ALL
SELECT 6, CAST(CONVERT(TIME(5),GETDATE()) AS VARCHAR(15))
UNION ALL
SELECT 7, CAST(CONVERT(TIME(6),GETDATE()) AS VARCHAR(15))
UNION ALL
SELECT 8, CAST(CONVERT(TIME(7),GETDATE()) AS VARCHAR(15))
UNION ALL
SELECT 9, CAST(CONVERT(TIME,GETDATE()) AS VARCHAR(15))

Insert value for Time Datatype in SQL Server example
 
Get Current System Time
The following query can be used to get the Current System Time
SELECT CONVERT(TIME(0),GETDATE())
 
 
Inserting Time Values in Table using SQL Query
Using the below query I have inserted some rows in the Meetings table
INSERT INTO Meetings
VALUES
('John', '12:00:00', '13:00:00'),
('Robert', '14:00:00', '14:30:00'),
('Maria', '15:00:00', '16:00:00')
After insert the table has following records.
Insert value for Time Datatype in SQL Server example