The function of go in SQL Server is detailed _mssql

Source: Internet
Author: User
Tags getdate sql server query create database

No nonsense, please read the detailed below.

Use Db_csharp
go
 select *,
 remark =case when 
 grade>=90 then ' excellent results ' when
 grade<90 and grade>=80 Then ' good grades ' when
 grade<80 and grade>=70 Then ' fail '
 Else ' fail ' End from 
 Tb_grade

If you're just executing a statement, there's no go.

It's different if multiple statements are separated by a go partition.

Each go-delimited statement is a separate transaction, and a statement execution failure does not affect the execution of other statements.

For example:

First execute the following statement at the same time

SELECT * from sysobjects where id=a
select GETDATE ()

You will find an error, and no result set will be displayed.

And you do it again.

SELECT * from sysobjects where id=a
go
select getdate ()
go

You will find that, although the error is the same, the result set contains the result of the Select GETDATE ().

Use of Go in Ps:sql SERVER

Signals the end of a batch of Transact-SQL statements by Microsoft®sql Server™ utility.
Go is NOT a Transact-SQL statement, but a command that can be identified for osql and isql utilities and SQL Server Query Analyzer.

If your SQL is too long, to write go, or some statements, it can only be the first line of operation, before you have to write go, it means that the batch processing statement with this go, to carry out the line code, execute and then execute the next code ...

In cases like this, go, batch processing data ...

Use master
go

if exists (SELECT * from sysdatabases where name = ' kejiandb ')
drop database kejiandb
go
   
    create database kejiandb go to

kejiandb
Go


-(industry table)
CREATE TABLE Trade
(
tra_id int Primary key identity (1,1) NOT null--industry ID (primary key, self-growing)
tra_name varchar () NOT null-industry name) go


   

The above is the entire narrative of this article, I hope you like.

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.