Code
-- Transactions
Set Transaction Isolation Level Repeatable Read
Begin Transaction
-- Insert Delete update select
If @ Error <> 0
Begin
Rollback Transaction
End
Commit Transaction
-- Variable
Declare @ Name Varchar ( 20 ) -- Statement
Select @ Name = ' Zhangsan ' -- Assignment
-- Stored Procedure
Create Proc Sp_demo @ Param1 Char ( 10 ), @ Param2 Varchar ( 20 ), @ Param3 Varchar ( 20 ), @ Param4 Int Output
With Encryption -- Encryption
As
Insert Table1 (column1, column2, column3)
Values ( @ Param1 , @ Param2 , @ Param3 )
Select @ Param4 = Sum ( Money ) From Bankmoney Where Userid = ' Zhangsan '
Go
Declare @ Total_price Int
Exec Insert_bank ' 004 ' , ' Zhangsan ' , ' Male ' , @ Total_price Output
Print ' The total balance is ' + Convert ( Varchar , @ Total_price )
Go
-- A view is also a table. It is generally the intersection of multiple tables.
Create View Partitionedview
As
Select *
From Mydatabase. DBO. partitiontable1
Union All
Select *
From Server2.mydatabase. DBO. partitiontable2
Union All
Select *
From Server3.mydatabase. DBO. partitiontable3
-- Trigger
Create Trigger Tg_event On Event
For Insert
As
Begin
Insert Event_temp (ID, project_id, taji_id, [ Time ] , Event_type, event_miaoshu, drive_id)
Select ID, project_id, taji_id, [ Time ] , Event_type, event_miaoshu, drive_id
From Inserted
End