Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
Insert multiple parent-child records
SQL_Joins_RankingFunctions
TRAIN
InsertData.sql
Check Constraints
/Users/svetlanakanevskaa/Downloads/ACDB.sql
pivot example
Data row generator (good performance, w/o recursive CTE)
1
decimal_test
Please log in to post a comment.