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

### Methods

database_type indexes server_version supports_savepoints? supports_transaction_isolation_levels? tables views

### 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.

### Attributes

mssql_unicode_strings | [RW] | Whether to use N’’ to quote strings, which allows unicode characters inside the strings. True by default for compatibility, can be set to false for a possible performance increase. This sets the default for all datasets created from this Database object.

### Public Instance methods

database_type()

Microsoft SQL Server uses the :mssql type.

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 27
    27:       def database_type
    28:         :mssql
    29:       end

indexes(table, opts={})

Use the system tables to get index information

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 32
    32:       def indexes(table, opts={})
    33:         m = output_identifier_meth
    34:         im = input_identifier_meth
    35:         indexes = {}
    36:         metadata_dataset.from(:sys__tables___t).
    37:          join(:sys__indexes___i, :object_id=>:object_id).
    38:          join(:sys__index_columns___ic, :object_id=>:object_id, :index_id=>:index_id).
    39:          join(:sys__columns___c, :object_id=>:object_id, :column_id=>:column_id).
    40:          select(:i__name, :i__is_unique, :c__name___column).
    41:          where{{t__name=>im.call(table)}}.
    42:          where(:i__is_primary_key=>0, :i__is_disabled=>0).
    43:          order(:i__name, :ic__index_column_id).
    44:          each do |r|
    45:           index = indexes[m.call(r[:name])] ||= {:columns=>[], :unique=>(r[:is_unique] && r[:is_unique]!=0)}
    46:           index[:columns] << m.call(r[:column])
    47:         end
    48:         indexes
    49:       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 53
    53:       def server_version(server=nil)
    54:         return @server_version if @server_version
    55:         @server_version = synchronize(server) do |conn|
    56:           (conn.server_version rescue nil) if conn.respond_to?(:server_version)
    57:         end
    58:         unless @server_version
    59:           m = SERVER_VERSION_RE.match(fetch(SERVER_VERSION_SQL).single_value.to_s)
    60:           @server_version = (m[1].to_i * 1000000) + (m[2].to_i * 10000) + m[3].to_i
    61:         end
    62:         @server_version
    63:       end

supports_savepoints?()

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

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 66
    66:       def supports_savepoints?
    67:         true
    68:       end

supports_transaction_isolation_levels?()

MSSQL supports transaction isolation levels

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 71
    71:       def supports_transaction_isolation_levels?
    72:         true
    73:       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 77
    77:       def tables(opts={})
    78:         information_schema_tables('BASE TABLE', opts)
    79:       end

views(opts={})

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

[Source]

        # File lib/sequel/adapters/shared/mssql.rb, line 83
    83:       def views(opts={})
    84:         information_schema_tables('VIEW', opts)
    85:       end

[Validate]