Start and End of Statement in SQL Server Transact-SQL

Q

How to start and end a statement in SQL Server Transact-SQL?

✍: FYIcenter.com

A

Here are some simple rules about writing statements in SQL Server Transact-SQL:

  • A Transact-SQL statement must be started with a pre-defined statement keyword.
  • A Transact-SQL statement must be ended with a new line (/n) or a semicolon (;) character.
  • A Transact-SQL statement can be entered in multiple lines.
  • Multiple Transact-SQL statements can be entered in a single line.
  • Transact-SQL statement keywords are case-insensitive.
  • Extra white space characters are ignored within Transact-SQL statements.

Here are some examples on how to write Transact-SQL statement:

CREATE TABLE fyi_links (id INTEGER PRIMARY KEY,
  url VARCHAR(80) NOT NULL,
  notes VARCHAR(1024),
  counts INT,
  created DATETIME NOT NULL DEFAULT(getdate()));
 
SeLeCT 'Welcome to FYIcenter.com SQL Server!';

Print 'Come visit this page again!'

PRINT 'Hello World!'; SELECT GETDATE();

As a best practice, you should always start a Transact-SQL statement on a new line and you should always end a Transact-SQL statement with semicolon (;).

 

Comments in SQL Server Transact-SQL Statements

What Is a Statement in SQL Server Transact-SQL

General Questions on Microsoft SQL Server Transact-SQL

⇑⇑ SQL Server Transact-SQL Tutorials

2017-05-29, 1726🔥, 0💬