Common SQL Server

Source: Internet
Author: User

 

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  

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.