суббота, 7 сентября 2013 г.

Пример использования системных функций



SELECT
    @@SPID AS SPID
    , @@SERVERNAME AS SERVERNAME
    , @@SERVICENAME AS SERVICENAME
    , SYSTEM_USER AS "SYSTEM_USER"
    ,USER AS "User"
    ,DB_NAME() AS "Current DB"
    ,@@TRANCOUNT AS "Trans"
    ,@@ERROR AS Error


SELECT DB_ID('Master') AS DB_ID
SELECT DB_ID('Specialist') AS DB_ID
SELECT DB_ID('DB10') AS DB_ID
USE Specialist
SELECT OBJECT_ID('Course') AS Object_ID
USE Master
SELECT OBJECT_ID('Course') AS Object_ID

SELECT DB_NAME(2)

SELECT DB_NAME(0)