module Sequel::MSSQL::DatabaseMethods

Constants

AUTO_INCREMENT
DECIMAL_TYPE_RE

The types to check for 0 scale to transform :decimal types to :integer.

SERVER_VERSION_RE
SERVER_VERSION_SQL
SQL_BEGIN
SQL_COMMIT
SQL_ROLLBACK
SQL_ROLLBACK_TO_SAVEPOINT
SQL_SAVEPOINT

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() click to toggle source

Microsoft SQL Server uses the :mssql type.

# File lib/sequel/adapters/shared/mssql.rb, line 27
def database_type
  :mssql
end
global_index_namespace?() click to toggle source

Microsoft SQL Server namespaces indexes per table.

# File lib/sequel/adapters/shared/mssql.rb, line 32
def global_index_namespace?
  false
end
indexes(table, opts={}) click to toggle source

Use the system tables to get index information

# File lib/sequel/adapters/shared/mssql.rb, line 37
def indexes(table, opts={})
  m = output_identifier_meth
  im = input_identifier_meth
  indexes = {}
  metadata_dataset.from(:sys__tables___t).
   join(:sys__indexes___i, :object_id=>:object_id).
   join(:sys__index_columns___ic, :object_id=>:object_id, :index_id=>:index_id).
   join(:sys__columns___c, :object_id=>:object_id, :column_id=>:column_id).
   select(:i__name, :i__is_unique, :c__name___column).
   where{{t__name=>im.call(table)}}.
   where(:i__is_primary_key=>0, :i__is_disabled=>0).
   order(:i__name, :ic__index_column_id).
   each do |r|
    index = indexes[m.call(r[:name])] ||= {:columns=>[], :unique=>(r[:is_unique] && r[:is_unique]!=0)}
    index[:columns] << m.call(r[:column])
  end
  indexes
end
server_version(server=nil) click to toggle source

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

# File lib/sequel/adapters/shared/mssql.rb, line 58
def server_version(server=nil)
  return @server_version if @server_version
  @server_version = synchronize(server) do |conn|
    (conn.server_version rescue nil) if conn.respond_to?(:server_version)
  end
  unless @server_version
    m = SERVER_VERSION_RE.match(fetch(SERVER_VERSION_SQL).single_value.to_s)
    @server_version = (m[1].to_i * 1000000) + (m[2].to_i * 10000) + m[3].to_i
  end
  @server_version
end
supports_savepoints?() click to toggle source

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

# File lib/sequel/adapters/shared/mssql.rb, line 71
def supports_savepoints?
  true
end
supports_transaction_isolation_levels?() click to toggle source

MSSQL supports transaction isolation levels

# File lib/sequel/adapters/shared/mssql.rb, line 76
def supports_transaction_isolation_levels?
  true
end
supports_transactional_ddl?() click to toggle source

MSSQL supports transaction DDL statements.

# File lib/sequel/adapters/shared/mssql.rb, line 81
def supports_transactional_ddl?
  true
end
tables(opts={}) click to toggle source

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

# File lib/sequel/adapters/shared/mssql.rb, line 87
def tables(opts={})
  information_schema_tables('BASE TABLE', opts)
end
views(opts={}) click to toggle source

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

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