Home  >  Article  >  Database  >  SQLServer 中.与::的区别

SQLServer 中.与::的区别

WBOY
WBOYOriginal
2016-06-07 17:58:521242browse

SQL Server中调用方法时,经常遇到.或是::两种调用方法,其中. 是实例调用方法,::是静态调用方法。如果大家对C#语法熟悉的话,. 对应C#中调用实例方法,:: 对应C#中的static方法。

下面给出一个SQL Server的实例,下面的SQL运行在2008环境下:

DECLARE @g geography;
SET @g = geography::Parse('LINESTRING(-122.360 47.656, -122.343 47.656)');

SELECT @g;
SELECT @g.ToString();

结果集为:

0xE610000001148716D9CEF7D34740D7A3703D0A975EC08716D9CEF7D34740CBA145B6F3955EC0

LINESTRING (-122.36 47.656, -122.343 47.656)

geography是SQL Server 2008新增的支持地理信息类型,由于超出本文所讲范围,所以这里不做说明。

我们只看里面的geography::Parse方法和@g.ToString()方法,可以看到Parse方法是通过geography类型支持调用的,相当于C#中的Class.StaticMethod形式,ToString()是通过g这个实例调用的。

如需转载,请注明本文原创自CSDN TJVictor专栏
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn