Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Primary key and unique key for single column and multi columns
select convert(date,getdate()) -- create primary key combine multi column CREATE TABLE TestTable (ID INT, Value1 INT,Value2 int,Total as (Value1+Value2),date datetimeoffset,constraint pk_id_Value1 primary key(id,value1)) -- create primary key and index for single column CREATE TABLE TestTable1 (ID INT not null primary key, Value1 INT not null unique,Value2 int,Total as (Value1+Value2),date datetimeoffset) INSERT INTO TestTable (ID, Value1,Value2,date) SELECT 1, 10,10,getdate() UNION ALL SELECT 2, 10,20,SYSDATETIMEOFFSET() UNION ALL SELECT 3, 30,30,getdate() UNION ALL SELECT 4, 40,40,getdate() UNION ALL SELECT 5, 50,50,getdate() UNION ALL SELECT 6, 60,60,getdate() UNION ALL SELECT 7, 70,70,getdate() GO SELECT ID, Value1,Value2,Total,date,SYSDATETIMEOFFSET() as 'offsetdate' FROM TestTable
run
|
edit
|
history
|
help
0
subaco
Hotel BD
20181CSE0041
Show slowest queries
Ranking split across tournaments
group for team members and winners in sql-server
Comercio
Task_5_Final
MyShopSchema
20181CSE0041