Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of "::" in T-SQL

In (non-English) book on T-SQL (SQL Server 2005) I read about:

SELECT * FROM ::fn_helpcollations()

Though, execution of it without "::"

SELECT * FROM fn_helpcollations()

In my SQL Server 2008 R2 gives exactly the same result.

What does "::" mean in T-SQL?

like image 548

People also ask

What does :: do in SQL?

In MS SQL Server 2000: For built-in user-defined functions that return a table, the function name must be specified with a leading double colon (::) to distinguish it from user-defined functions that are not built-in. It also must be specified as a one-part name with no database or owner qualifications.

What is T-SQL block?

TSQL is a query language, but it is an extension of SQL that serves Microsoft SQL Server databases and software. 8. Operations. In Structured Query language, we perform DML and DDL operations. In Transact Structured Query, there is a block of codes that used to write function and procedure.

What's the difference between T-SQL and SQL?

The obvious difference is in what they are designed for: SQL is a​ query language used for manipulating data stored in a database. T-SQL is also a query language, but it's an extension of SQL that is primarily used in Microsoft SQL Server databases and software.

Is it necessary to put semicolon in SQL?

Some database systems require a semicolon at the end of each SQL statement. Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server. In this tutorial, we will use semicolon at the end of each SQL statement.


1 Answers

From MSDN:

However, when you call SQL Server built-in functions that return a table, you must add the prefix :: to the name of the function:

SELECT * FROM ::fn_helpcollations()

Looks like you can omit the :: in SQL Server 2005 and 2008. The :: syntax will be supported for backward compatibility.

like image 170
Andomar Avatar answered Sep 25 '22 21:09

Andomar