Module | Sequel::MSSQL::DatabaseMethods
In: | lib/sequel/adapters/shared/mssql.rb

### Methods

database_type server_version supports_savepoints? supports_transaction_isolation_levels? tables

### Constants

AUTO_INCREMENT | = | 'IDENTITY(1,1)'.freeze
SERVER_VERSION_RE | = | /^(\d+)\.(\d+)\.(\d+)/.freeze
SERVER_VERSION_SQL | = | "SELECT CAST(SERVERPROPERTY('ProductVersion') AS varchar)".freeze
SQL_BEGIN | = | "BEGIN TRANSACTION".freeze
SQL_COMMIT | = | "COMMIT TRANSACTION".freeze
SQL_ROLLBACK | = | "IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION".freeze
SQL_ROLLBACK_TO_SAVEPOINT | = | 'IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION autopoint_%d'.freeze
SQL_SAVEPOINT | = | 'SAVE TRANSACTION autopoint_%d'.freeze
DECIMAL_TYPE_RE | = | /number|numeric|decimal/io |  | The types to check for 0 scale to transform :decimal types to :integer.

### Public Instance methods

database_type()

Microsoft SQL Server uses the :mssql type.

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 19
    19:       def database_type
    20:         :mssql
    21:       end

server_version(server=nil)

The version of the MSSQL server, as an integer (e.g. 10001600 for SQL Server 2008 Express).

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 25
    25:       def server_version(server=nil)
    26:         return @server_version if @server_version
    27:         @server_version = synchronize(server) do |conn|
    28:           (conn.server_version rescue nil) if conn.respond_to?(:server_version)
    29:         end
    30:         unless @server_version
    31:           m = SERVER_VERSION_RE.match(fetch(SERVER_VERSION_SQL).single_value.to_s)
    32:           @server_version = (m[1].to_i * 1000000) + (m[2].to_i * 10000) + m[3].to_i
    33:         end
    34:         @server_version
    35:       end

supports_savepoints?()

MSSQL supports savepoints, though it doesn‘t support committing/releasing them savepoint

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 38
    38:       def supports_savepoints?
    39:         true
    40:       end

supports_transaction_isolation_levels?()

MSSQL supports transaction isolation levels

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 43
    43:       def supports_transaction_isolation_levels?
    44:         true
    45:       end

tables(opts={})

Microsoft SQL Server supports using the INFORMATION_SCHEMA to get information on tables.

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 49
    49:       def tables(opts={})
    50:         m = output_identifier_meth
    51:         metadata_dataset.from(:information_schema__tables___t).
    52:           select(:table_name).
    53:           filter(:table_type=>'BASE TABLE', :table_schema=>(opts[:schema]||default_schema||'dbo').to_s).
    54:           map{|x| m.call(x[:table_name])}
    55:       end

[Validate]