In any programming language, there are some standard defined data types, even in SQL (Structured Query Language) which is used for database programming, has some certain data type, here you learn all sql data types with example.
Data Types in SQL is an attribute, which tells the type of data of any column, variable and expression has a related data type in Sql.
As you can see in above picture diagram, you can define data type while creating a table, also can alter the data type for any particular column, however if there is data of different type which are not convertible, that that may cause an error.
Here is the SQL code of defining sql data type at the time of creating or altering a Table
Create TABLE [dbo].[tbWeek]( [WeekId] [int] IDENTITY(1,1) NOT NULL, [WeekName] [varchar](50) NOT NULL, [UpdateDate] [datetime] NOT NULL, [CreateDate] [date] NULL, [NoOfHolidays] [int] NULL, PRIMARY KEY CLUSTERED ( [WeekId] ASC ) ON [PRIMARY] )
Here is an example of how you can alter column data type in sql table.
Notice, when i created the table with above script, the column "WeekName" was defined as Varchar data type, now i change the data type to nvarchar data type.
ALTER TABLE tbWeek ALTER COLUMN [WeekName] nvarchar(50); GO
Here are the different data type examples in SQL Database
All different type string data type that sql server supports.
Here are different type numeric data type that sql server supports.
Learn more about sql datetime functions and data type