### Home Classes Methods

### In Files

- lib/sequel/adapters/shared/mssql.rb

### Methods

- #alter_table_sql
- #auto_increment_sql
- #begin_savepoint_sql
- #begin_transaction_sql
- #commit_transaction
- #commit_transaction_sql
- #create_table_sql
- #database_type
- #default_constraint_name
- #drop_index_sql
- #index_definition_sql
- #indexes
- #information_schema_tables
- #metadata_dataset
- #rename_table_sql
- #rollback_savepoint_sql
- #rollback_transaction_sql
- #schema_column_type
- #schema_parse_table
- #server_version
- #set_mssql_unicode_strings
- #supports_savepoints?
- #supports_transaction_isolation_levels?
- #tables
- #type_literal_generic_datetime
- #type_literal_generic_file
- #type_literal_generic_time
- #type_literal_generic_trueclass
- #views

### Files

- CHANGELOG
- MIT-LICENSE
- README.rdoc
- active_record.rdoc
- advanced_associations.rdoc
- association_basics.rdoc
- cheat_sheet.rdoc
- dataset_basics.rdoc
- dataset_filtering.rdoc
- mass_assignment.rdoc
- migration.rdoc
- model_hooks.rdoc
- opening_databases.rdoc
- prepared_statements.rdoc
- querying.rdoc
- reflection.rdoc
- 1.0.txt
- 1.1.txt
- 1.3.txt
- 1.4.0.txt
- 1.5.0.txt
- 2.0.0.txt
- 2.1.0.txt
- 2.10.0.txt
- 2.11.0.txt
- 2.12.0.txt
- 2.2.0.txt
- 2.3.0.txt
- 2.4.0.txt
- 2.5.0.txt
- 2.6.0.txt
- 2.7.0.txt
- 2.8.0.txt
- 2.9.0.txt
- 3.0.0.txt
- 3.1.0.txt
- 3.10.0.txt
- 3.11.0.txt
- 3.12.0.txt
- 3.13.0.txt
- 3.14.0.txt
- 3.15.0.txt
- 3.16.0.txt
- 3.17.0.txt
- 3.18.0.txt
- 3.19.0.txt
- 3.2.0.txt
- 3.20.0.txt
- 3.21.0.txt
- 3.22.0.txt
- 3.23.0.txt
- 3.24.0.txt
- 3.25.0.txt
- 3.26.0.txt
- 3.27.0.txt
- 3.28.0.txt
- 3.29.0.txt
- 3.3.0.txt
- 3.30.0.txt
- 3.31.0.txt
- 3.32.0.txt
- 3.33.0.txt
- 3.4.0.txt
- 3.5.0.txt
- 3.6.0.txt
- 3.7.0.txt
- 3.8.0.txt
- 3.9.0.txt
- schema_modification.rdoc
- sharding.rdoc
- sql.rdoc
- testing.rdoc
- transactions.rdoc
- validations.rdoc
- virtual_rows.rdoc

### Class Index

Quicksearch

- Sequel
- Sequel::ADO
- Sequel::ADO::Database
- Sequel::ADO::Dataset
- Sequel::ADO::MSSQL
- Sequel::ADO::MSSQL::DatabaseMethods
- Sequel::ADO::MSSQL::Dataset
- Sequel::ASTTransformer
- Sequel::Access
- Sequel::Access::DatabaseMethods
- Sequel::Access::DatasetMethods
- Sequel::Adapter
- Sequel::AdapterNotFound
- Sequel::AdapterNotFound
- Sequel::Amalgalite
- Sequel::Amalgalite::Database
- Sequel::Amalgalite::Dataset
- Sequel::Amalgalite::SequelTypeMap
- Sequel::ArbitraryServers
- Sequel::BasicObject
- Sequel::ColumnsIntrospection
- Sequel::ConnectionPool
- Sequel::ConnectionPool::ClassMethods
- Sequel::DB2
- Sequel::DB2::DB2Error
- Sequel::DB2::Database
- Sequel::DB2::DatabaseMethods
- Sequel::DB2::Dataset
- Sequel::DB2::DatasetMethods
- Sequel::DBI
- Sequel::DBI::Database
- Sequel::DBI::Dataset
- Sequel::DataObjects
- Sequel::DataObjects::Database
- Sequel::DataObjects::Dataset
- Sequel::DataObjects::MySQL
- Sequel::DataObjects::MySQL::DatabaseMethods
- Sequel::DataObjects::MySQL::Dataset
- Sequel::DataObjects::Postgres
- Sequel::DataObjects::Postgres::AdapterMethods
- Sequel::DataObjects::Postgres::DatabaseMethods
- Sequel::DataObjects::Postgres::Dataset
- Sequel::DataObjects::SQLite
- Sequel::DataObjects::SQLite::DatabaseMethods
- Sequel::DataObjects::SQLite::Dataset
- Sequel::Database
- Sequel::DatabaseConnectionError
- Sequel::DatabaseDisconnectError
- Sequel::DatabaseError
- Sequel::Dataset
- Sequel::Dataset
- Sequel::Dataset::ArgumentMapper
- Sequel::Dataset::BindArgumentMethods
- Sequel::Dataset::Pagination
- Sequel::Dataset::PreparedStatementMethods
- Sequel::Dataset::QueryBlockCopy
- Sequel::Dataset::StoredProcedureMethods
- Sequel::Dataset::StoredProcedures
- Sequel::Dataset::TYPE_TRANSLATOR
- Sequel::Dataset::UnnumberedArgumentMapper
- Sequel::EmulateOffsetWithRowNumber
- Sequel::Error
- Sequel::Firebird
- Sequel::Firebird::Database
- Sequel::Firebird::DatabaseMethods
- Sequel::Firebird::Dataset
- Sequel::Firebird::DatasetMethods
- Sequel::HookFailed
- Sequel::HookFailed
- Sequel::IBMDB
- Sequel::IBMDB::Connection
- Sequel::IBMDB::Connection::Error
- Sequel::IBMDB::Database
- Sequel::IBMDB::Dataset
- Sequel::IBMDB::Dataset::CallableStatementMethods
- Sequel::IBMDB::Dataset::PreparedStatementMethods
- Sequel::IBMDB::Statement
- Sequel::Inflections
- Sequel::Informix
- Sequel::Informix::Database
- Sequel::Informix::DatabaseMethods
- Sequel::Informix::Dataset
- Sequel::Informix::DatasetMethods
- Sequel::IntegerMigrator
- Sequel::InvalidOperation
- Sequel::InvalidOperation
- Sequel::InvalidValue
- Sequel::InvalidValue
- Sequel::JDBC
- Sequel::JDBC::AS400
- Sequel::JDBC::AS400::DatabaseMethods
- Sequel::JDBC::AS400::Dataset
- Sequel::JDBC::DB2
- Sequel::JDBC::DB2::DatabaseMethods
- Sequel::JDBC::DB2::Dataset
- Sequel::JDBC::Database
- Sequel::JDBC::Derby
- Sequel::JDBC::Derby::DatabaseMethods
- Sequel::JDBC::Derby::Dataset
- Sequel::JDBC::Firebird
- Sequel::JDBC::Firebird::DatabaseMethods
- Sequel::JDBC::Firebird::Dataset
- Sequel::JDBC::H2
- Sequel::JDBC::H2::DatabaseMethods
- Sequel::JDBC::H2::Dataset
- Sequel::JDBC::HSQLDB
- Sequel::JDBC::HSQLDB::DatabaseMethods
- Sequel::JDBC::HSQLDB::Dataset
- Sequel::JDBC::Informix
- Sequel::JDBC::Informix::DatabaseMethods
- Sequel::JDBC::Informix::Dataset
- Sequel::JDBC::JTDS
- Sequel::JDBC::JTDS::DatabaseMethods
- Sequel::JDBC::JTDS::Dataset
- Sequel::JDBC::JavaLang
- Sequel::JDBC::JavaSQL
- Sequel::JDBC::JavaxNaming
- Sequel::JDBC::MSSQL
- Sequel::JDBC::MSSQL::DatabaseMethods
- Sequel::JDBC::MySQL
- Sequel::JDBC::MySQL::DatabaseMethods
- Sequel::JDBC::MySQL::Dataset
- Sequel::JDBC::Oracle
- Sequel::JDBC::Oracle::DatabaseMethods
- Sequel::JDBC::Oracle::Dataset
- Sequel::JDBC::Postgres
- Sequel::JDBC::Postgres::AdapterMethods
- Sequel::JDBC::Postgres::DatabaseMethods
- Sequel::JDBC::Postgres::Dataset
- Sequel::JDBC::SQLServer
- Sequel::JDBC::SQLServer::DatabaseMethods
- Sequel::JDBC::SQLServer::DatabaseMethods::MetadataDatasetMethods
- Sequel::JDBC::SQLServer::Dataset
- Sequel::JDBC::SQLite
- Sequel::JDBC::SQLite::DatabaseMethods
- Sequel::JDBC::SQLite::Dataset
- Sequel::JDBC::Transactions
- Sequel::LiteralString
- Sequel::LooserTypecasting
- Sequel::MSSQL
- Sequel::MSSQL::DatabaseMethods
- Sequel::MSSQL::DatasetMethods
- Sequel::Metaprogramming
- Sequel::Migration
- Sequel::MigrationAlterTableReverser
- Sequel::MigrationDSL
- Sequel::MigrationReverser
- Sequel::Migrator
- Sequel::Migrator::Error
- Sequel::Mock
- Sequel::Mock::Connection
- Sequel::Mock::Database
- Sequel::Mock::Dataset
- Sequel::Model
- Sequel::Model::Associations
- Sequel::Model::Associations::AssociationDatasetMethods
- Sequel::Model::Associations::AssociationReflection
- Sequel::Model::Associations::ClassMethods
- Sequel::Model::Associations::DatasetMethods
- Sequel::Model::Associations::EagerGraphLoader
- Sequel::Model::Associations::InstanceMethods
- Sequel::Model::Associations::ManyToManyAssociationReflection
- Sequel::Model::Associations::ManyToOneAssociationReflection
- Sequel::Model::Associations::OneToManyAssociationReflection
- Sequel::Model::Associations::OneToOneAssociationReflection
- Sequel::Model::ClassMethods
- Sequel::Model::DatasetMethods
- Sequel::Model::Errors
- Sequel::Model::InstanceMethods
- Sequel::MySQL
- Sequel::MySQL::DatabaseMethods
- Sequel::MySQL::DatasetMethods
- Sequel::MySQL::DatasetMethods::CallableStatementMethods
- Sequel::MySQL::DatasetMethods::PreparedStatementMethods
- Sequel::MySQL::DatasetMethods::StoredProcedureMethods
- Sequel::MySQL::PreparedStatements
- Sequel::MySQL::PreparedStatements::DatabaseMethods
- Sequel::Mysql2
- Sequel::Mysql2::Database
- Sequel::Mysql2::Dataset
- Sequel::NamedTimezones
- Sequel::NoExistingObject
- Sequel::NoExistingObject
- Sequel::NotImplemented
- Sequel::ODBC
- Sequel::ODBC::DB2
- Sequel::ODBC::DB2::DatabaseMethods
- Sequel::ODBC::DB2::Dataset
- Sequel::ODBC::Database
- Sequel::ODBC::Dataset
- Sequel::ODBC::MSSQL
- Sequel::ODBC::MSSQL::DatabaseMethods
- Sequel::ODBC::MSSQL::Dataset
- Sequel::OpenBase
- Sequel::OpenBase::Database
- Sequel::OpenBase::Dataset
- Sequel::Oracle
- Sequel::Oracle::Database
- Sequel::Oracle::DatabaseMethods
- Sequel::Oracle::DatasetMethods
- Sequel::Plugins
- Sequel::Plugins::ActiveModel
- Sequel::Plugins::ActiveModel::ClassMethods
- Sequel::Plugins::ActiveModel::InstanceMethods
- Sequel::Plugins::AssociationAutoreloading
- Sequel::Plugins::AssociationAutoreloading::ClassMethods
- Sequel::Plugins::AssociationDependencies
- Sequel::Plugins::AssociationDependencies::ClassMethods
- Sequel::Plugins::AssociationDependencies::InstanceMethods
- Sequel::Plugins::AssociationPks
- Sequel::Plugins::AssociationPks::ClassMethods
- Sequel::Plugins::AssociationPks::InstanceMethods
- Sequel::Plugins::AssociationProxies
- Sequel::Plugins::AssociationProxies::AssociationProxy
- Sequel::Plugins::AssociationProxies::ClassMethods
- Sequel::Plugins::BooleanReaders
- Sequel::Plugins::BooleanReaders::ClassMethods
- Sequel::Plugins::Caching
- Sequel::Plugins::Caching::ClassMethods
- Sequel::Plugins::Caching::InstanceMethods
- Sequel::Plugins::ClassTableInheritance
- Sequel::Plugins::ClassTableInheritance::ClassMethods
- Sequel::Plugins::ClassTableInheritance::InstanceMethods
- Sequel::Plugins::Composition
- Sequel::Plugins::Composition::ClassMethods
- Sequel::Plugins::Composition::InstanceMethods
- Sequel::Plugins::DatasetAssociations
- Sequel::Plugins::DatasetAssociations::ClassMethods
- Sequel::Plugins::DatasetAssociations::DatasetMethods
- Sequel::Plugins::DefaultsSetter
- Sequel::Plugins::DefaultsSetter::ClassMethods
- Sequel::Plugins::DefaultsSetter::InstanceMethods
- Sequel::Plugins::ForceEncoding
- Sequel::Plugins::ForceEncoding::ClassMethods
- Sequel::Plugins::ForceEncoding::InstanceMethods
- Sequel::Plugins::HookClassMethods
- Sequel::Plugins::HookClassMethods::ClassMethods
- Sequel::Plugins::HookClassMethods::InstanceMethods
- Sequel::Plugins::IdentityMap
- Sequel::Plugins::IdentityMap::ClassMethods
- Sequel::Plugins::IdentityMap::InstanceMethods
- Sequel::Plugins::InstanceFilters
- Sequel::Plugins::InstanceFilters::InstanceMethods
- Sequel::Plugins::InstanceHooks
- Sequel::Plugins::InstanceHooks::InstanceMethods
- Sequel::Plugins::JsonSerializer
- Sequel::Plugins::JsonSerializer::ClassMethods
- Sequel::Plugins::JsonSerializer::DatasetMethods
- Sequel::Plugins::JsonSerializer::InstanceMethods
- Sequel::Plugins::JsonSerializer::Literal
- Sequel::Plugins::LazyAttributes
- Sequel::Plugins::LazyAttributes::ClassMethods
- Sequel::Plugins::LazyAttributes::InstanceMethods
- Sequel::Plugins::List
- Sequel::Plugins::List::ClassMethods
- Sequel::Plugins::List::InstanceMethods
- Sequel::Plugins::ManyThroughMany
- Sequel::Plugins::ManyThroughMany::ClassMethods
- Sequel::Plugins::ManyThroughMany::DatasetMethods
- Sequel::Plugins::ManyThroughMany::ManyThroughManyAssociationReflection
- Sequel::Plugins::NestedAttributes
- Sequel::Plugins::NestedAttributes::ClassMethods
- Sequel::Plugins::NestedAttributes::InstanceMethods
- Sequel::Plugins::OptimisticLocking
- Sequel::Plugins::OptimisticLocking::ClassMethods
- Sequel::Plugins::OptimisticLocking::InstanceMethods
- Sequel::Plugins::PreparedStatements
- Sequel::Plugins::PreparedStatements::ClassMethods
- Sequel::Plugins::PreparedStatements::InstanceMethods
- Sequel::Plugins::PreparedStatementsAssociations
- Sequel::Plugins::PreparedStatementsAssociations::ClassMethods
- Sequel::Plugins::PreparedStatementsAssociations::InstanceMethods
- Sequel::Plugins::PreparedStatementsSafe
- Sequel::Plugins::PreparedStatementsSafe::ClassMethods
- Sequel::Plugins::PreparedStatementsSafe::InstanceMethods
- Sequel::Plugins::PreparedStatementsWithPk
- Sequel::Plugins::PreparedStatementsWithPk::ClassMethods
- Sequel::Plugins::PreparedStatementsWithPk::DatasetMethods
- Sequel::Plugins::RcteTree
- Sequel::Plugins::Schema
- Sequel::Plugins::Schema::ClassMethods
- Sequel::Plugins::Serialization
- Sequel::Plugins::Serialization::ClassMethods
- Sequel::Plugins::Serialization::InstanceMethods
- Sequel::Plugins::SerializationModificationDetection
- Sequel::Plugins::SerializationModificationDetection::InstanceMethods
- Sequel::Plugins::Sharding
- Sequel::Plugins::Sharding::ClassMethods
- Sequel::Plugins::Sharding::DatasetMethods
- Sequel::Plugins::Sharding::InstanceMethods
- Sequel::Plugins::SingleTableInheritance
- Sequel::Plugins::SingleTableInheritance::ClassMethods
- Sequel::Plugins::SingleTableInheritance::InstanceMethods
- Sequel::Plugins::SkipCreateRefresh
- Sequel::Plugins::SkipCreateRefresh::InstanceMethods
- Sequel::Plugins::StringStripper
- Sequel::Plugins::StringStripper::InstanceMethods
- Sequel::Plugins::Subclasses
- Sequel::Plugins::Subclasses::ClassMethods
- Sequel::Plugins::TacticalEagerLoading
- Sequel::Plugins::TacticalEagerLoading::DatasetMethods
- Sequel::Plugins::TacticalEagerLoading::InstanceMethods
- Sequel::Plugins::Timestamps
- Sequel::Plugins::Timestamps::ClassMethods
- Sequel::Plugins::Timestamps::InstanceMethods
- Sequel::Plugins::Touch
- Sequel::Plugins::Touch::ClassMethods
- Sequel::Plugins::Touch::InstanceMethods
- Sequel::Plugins::Tree
- Sequel::Plugins::Tree::ClassMethods
- Sequel::Plugins::Tree::InstanceMethods
- Sequel::Plugins::Tree::SingleRoot
- Sequel::Plugins::Tree::SingleRoot::ClassMethods
- Sequel::Plugins::Tree::SingleRoot::InstanceMethods
- Sequel::Plugins::Tree::TreeMultipleRootError
- Sequel::Plugins::TypecastOnLoad
- Sequel::Plugins::TypecastOnLoad::ClassMethods
- Sequel::Plugins::TypecastOnLoad::InstanceMethods
- Sequel::Plugins::UpdatePrimaryKey
- Sequel::Plugins::UpdatePrimaryKey::ClassMethods
- Sequel::Plugins::UpdatePrimaryKey::InstanceMethods
- Sequel::Plugins::ValidationClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods::Generator
- Sequel::Plugins::ValidationClassMethods::InstanceMethods
- Sequel::Plugins::ValidationHelpers
- Sequel::Plugins::ValidationHelpers::InstanceMethods
- Sequel::Plugins::XmlSerializer
- Sequel::Plugins::XmlSerializer::ClassMethods
- Sequel::Plugins::XmlSerializer::DatasetMethods
- Sequel::Plugins::XmlSerializer::InstanceMethods
- Sequel::PoolTimeout
- Sequel::PoolTimeout
- Sequel::Postgres
- Sequel::Postgres::AdapterMethods
- Sequel::Postgres::DatabaseMethods
- Sequel::Postgres::DatasetMethods
- Sequel::Postgres::DatasetMethods::PreparedStatementMethods
- Sequel::PrettyTable
- Sequel::Progress
- Sequel::Progress::DatabaseMethods
- Sequel::Progress::DatasetMethods
- Sequel::Qualifier
- Sequel::Rollback
- Sequel::Rollback
- Sequel::SQL
- Sequel::SQL::AliasMethods
- Sequel::SQL::AliasedExpression
- Sequel::SQL::BitwiseMethods
- Sequel::SQL::Blob
- Sequel::SQL::BooleanConstant
- Sequel::SQL::BooleanExpression
- Sequel::SQL::BooleanMethods
- Sequel::SQL::CaseExpression
- Sequel::SQL::Cast
- Sequel::SQL::CastMethods
- Sequel::SQL::ColumnAll
- Sequel::SQL::ComplexExpression
- Sequel::SQL::ComplexExpressionMethods
- Sequel::SQL::Constant
- Sequel::SQL::Constants
- Sequel::SQL::Expression
- Sequel::SQL::Function
- Sequel::SQL::GenericComplexExpression
- Sequel::SQL::GenericExpression
- Sequel::SQL::Identifier
- Sequel::SQL::IdentifierMethods
- Sequel::SQL::InequalityMethods
- Sequel::SQL::JoinClause
- Sequel::SQL::JoinOnClause
- Sequel::SQL::JoinUsingClause
- Sequel::SQL::NegativeBooleanConstant
- Sequel::SQL::NoBooleanInputMethods
- Sequel::SQL::NumericExpression
- Sequel::SQL::NumericMethods
- Sequel::SQL::OrderMethods
- Sequel::SQL::OrderedExpression
- Sequel::SQL::PlaceholderLiteralString
- Sequel::SQL::QualifiedIdentifier
- Sequel::SQL::QualifyingMethods
- Sequel::SQL::StringConcatenationMethods
- Sequel::SQL::StringExpression
- Sequel::SQL::StringMethods
- Sequel::SQL::Subscript
- Sequel::SQL::SubscriptMethods
- Sequel::SQL::ValueList
- Sequel::SQL::ValueList
- Sequel::SQL::VirtualRow
- Sequel::SQL::Window
- Sequel::SQL::WindowFunction
- Sequel::SQLTime
- Sequel::SQLite
- Sequel::SQLite::DatabaseMethods
- Sequel::SQLite::DatasetMethods
- Sequel::Schema
- Sequel::Schema::AlterTableGenerator
- Sequel::Schema::Generator
- Sequel::ServerBlock
- Sequel::ShardedSingleConnectionPool
- Sequel::ShardedThreadedConnectionPool
- Sequel::SimpleMigration
- Sequel::SingleConnectionPool
- Sequel::Swift
- Sequel::Swift::Database
- Sequel::Swift::Dataset
- Sequel::Swift::MySQL
- Sequel::Swift::MySQL::DatabaseMethods
- Sequel::Swift::MySQL::Dataset
- Sequel::Swift::Postgres
- Sequel::Swift::Postgres::AdapterMethods
- Sequel::Swift::Postgres::DatabaseMethods
- Sequel::Swift::Postgres::Dataset
- Sequel::Swift::SQLite
- Sequel::Swift::SQLite::DatabaseMethods
- Sequel::Swift::SQLite::Dataset
- Sequel::ThreadLocalTimezones
- Sequel::ThreadedConnectionPool
- Sequel::ThreadedServerBlock
- Sequel::TimestampMigrator
- Sequel::Timezones
- Sequel::TinyTDS
- Sequel::TinyTDS::Database
- Sequel::TinyTDS::Dataset
- Sequel::TinyTDS::Dataset::ArgumentMapper
- Sequel::TinyTDS::Dataset::PreparedStatementMethods
- Sequel::ToDot
- Sequel::UnbindDuplicate
- Sequel::Unbinder
- Sequel::UndefinedAssociation
- Sequel::UnthreadedServerBlock
- Sequel::ValidationFailed
- Dataset
- Dataset::ArgumentMapper
- Dataset::BindArgumentMethods
- Dataset::PreparedStatementMethods
- String
- String::Inflections
- Array
- FalseClass
- Hash
- NilClass
- Numeric
- Object
- PGconn
- PGresult
- Proc
- Symbol
- TrueClass

No matching classes.

# Sequel::MSSQL::DatabaseMethods

### Constants

AUTO_INCREMENT
SERVER_VERSION_RE
SERVER_VERSION_SQL
SQL_BEGIN
SQL_COMMIT
SQL_ROLLBACK
SQL_ROLLBACK_TO_SAVEPOINT
SQL_SAVEPOINT
DECIMAL_TYPE_RE

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

Microsoft SQL Server uses the :mssql type.

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

indexes(table, opts={}) click to toggle source

Use the system tables to get index information

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

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

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

supports_transaction_isolation_levels?() click to toggle source

MSSQL supports transaction isolation levels

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

### Private Instance Methods

alter_table_sql(table, op) click to toggle source

MSSQL specific syntax for altering tables.

         # File lib/sequel/adapters/shared/mssql.rb, line 95
     95:       def alter_table_sql(table, op)
     96:         case op[:op]
     97:         when :add_column
     98:           "ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}"
     99:         when :rename_column
    100:           "sp_rename #{literal("#{quote_schema_table(table)}.#{quote_identifier(op[:name])}")}, #{literal(op[:new_name].to_s)}, 'COLUMN'"
    101:         when :set_column_type
    102:           sqls = []
    103:           if sch = schema(table)
    104:             if cs = sch.each{|k, v| break v if k == op[:name]; nil}
    105:               cs = cs.dup
    106:               if constraint = default_constraint_name(table, op[:name])
    107:                 sqls << "ALTER TABLE #{quote_schema_table(table)} DROP CONSTRAINT #{constraint}"
    108:               end
    109:               cs[:default] = cs[:ruby_default]
    110:               op = cs.merge!(op)
    111:               default = op.delete(:default)
    112:             end
    113:           end
    114:           sqls << "ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{column_definition_sql(op)}"
    115:           sqls << alter_table_sql(table, op.merge(:op=>:set_column_default, :default=>default)) if default
    116:           sqls
    117:         when :set_column_null
    118:           sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last
    119:           type = sch[:db_type]
    120:           if [:string, :decimal].include?(sch[:type]) and size = (sch[:max_chars] || sch[:column_size])
    121:             type += "(#{size}#{", #{sch[:scale]}" if sch[:scale] && sch[:scale].to_i > 0})"
    122:           end
    123:           "ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(:type=>type)} #{'NOT ' unless op[:null]}NULL"
    124:         when :set_column_default
    125:           "ALTER TABLE #{quote_schema_table(table)} ADD CONSTRAINT #{quote_identifier("sequel_#{table}_#{op[:name]}_def")} DEFAULT #{literal(op[:default])} FOR #{quote_identifier(op[:name])}"
    126:         else
    127:           super(table, op)
    128:         end
    129:       end

auto_increment_sql() click to toggle source

MSSQL uses the IDENTITY(1,1) column for autoincrementing columns.

        # File lib/sequel/adapters/shared/mssql.rb, line 90
    90:       def auto_increment_sql
    91:         AUTO_INCREMENT
    92:       end

begin_savepoint_sql(depth) click to toggle source

SQL to start a new savepoint

         # File lib/sequel/adapters/shared/mssql.rb, line 132
    132:       def begin_savepoint_sql(depth)
    133:         SQL_SAVEPOINT % depth
    134:       end

begin_transaction_sql() click to toggle source

SQL to BEGIN a transaction.

         # File lib/sequel/adapters/shared/mssql.rb, line 137
    137:       def begin_transaction_sql
    138:         SQL_BEGIN
    139:       end

commit_transaction(conn, opts={}) click to toggle source

Commit the active transaction on the connection, does not commit/release savepoints.

         # File lib/sequel/adapters/shared/mssql.rb, line 143
    143:       def commit_transaction(conn, opts={})
    144:         log_connection_execute(conn, commit_transaction_sql) unless @transactions[conn][:savepoint_level] > 1
    145:       end

commit_transaction_sql() click to toggle source

SQL to COMMIT a transaction.

         # File lib/sequel/adapters/shared/mssql.rb, line 148
    148:       def commit_transaction_sql
    149:         SQL_COMMIT
    150:       end

create_table_sql(name, generator, options) click to toggle source

MSSQL uses the name of the table to decide the difference between a regular and temporary table, with temporary table names starting with a #.

         # File lib/sequel/adapters/shared/mssql.rb, line 155
    155:       def create_table_sql(name, generator, options)
    156:         "CREATE TABLE #{quote_schema_table(options[:temp] ? "##{name}" : name)} (#{column_list_sql(generator)})"
    157:       end

default_constraint_name(table, column) click to toggle source

The name of the constraint for setting the default value on the table and column.

         # File lib/sequel/adapters/shared/mssql.rb, line 160
    160:       def default_constraint_name(table, column)
    161:         from(:sysobjects___c_obj).
    162:           join(:syscomments___com, :id=>:id).
    163:           join(:sysobjects___t_obj, :id=>:c_obj__parent_obj).
    164:           join(:sysconstraints___con, :constid=>:c_obj__id).
    165:           join(:syscolumns___col, :id=>:t_obj__id, :colid=>:colid).
    166:           where{{c_obj__uid=>user_id{}}}.
    167:           where(:c_obj__xtype=>'D', :t_obj__name=>table.to_s, :col__name=>column.to_s).
    168:           get(:c_obj__name)
    169:       end

drop_index_sql(table, op) click to toggle source

The SQL to drop an index for the table.

         # File lib/sequel/adapters/shared/mssql.rb, line 172
    172:       def drop_index_sql(table, op)
    173:         "DROP INDEX #{quote_identifier(op[:name] || default_index_name(table, op[:columns]))} ON #{quote_schema_table(table)}"
    174:       end

index_definition_sql(table_name, index) click to toggle source

support for clustered index type

         # File lib/sequel/adapters/shared/mssql.rb, line 281
    281:       def index_definition_sql(table_name, index)
    282:         index_name = index[:name] || default_index_name(table_name, index[:columns])
    283:         raise Error, "Partial indexes are not supported for this database" if index[:where]
    284:         if index[:type] == :full_text
    285:           "CREATE FULLTEXT INDEX ON #{quote_schema_table(table_name)} #{literal(index[:columns])} KEY INDEX #{literal(index[:key_index])}"
    286:         else
    287:           "CREATE #{'UNIQUE ' if index[:unique]}#{'CLUSTERED ' if index[:type] == :clustered}INDEX #{quote_identifier(index_name)} ON #{quote_schema_table(table_name)} #{literal(index[:columns])}#{" INCLUDE #{literal(index[:include])}" if index[:include]}"
    288:         end
    289:       end

information_schema_tables(type, opts) click to toggle source

Backbone of the tables and views support.

         # File lib/sequel/adapters/shared/mssql.rb, line 177
    177:       def information_schema_tables(type, opts)
    178:         m = output_identifier_meth
    179:         metadata_dataset.from(:information_schema__tables___t).
    180:           select(:table_name).
    181:           filter(:table_type=>type, :table_schema=>(opts[:schema]||default_schema||'dbo').to_s).
    182:           map{|x| m.call(x[:table_name])}
    183:       end

metadata_dataset() click to toggle source

Always quote identifiers in the metadata_dataset, so schema parsing works.

         # File lib/sequel/adapters/shared/mssql.rb, line 186
    186:       def metadata_dataset
    187:         ds = super
    188:         ds.quote_identifiers = true
    189:         ds
    190:       end

rename_table_sql(name, new_name) click to toggle source

Use sp_rename to rename the table

         # File lib/sequel/adapters/shared/mssql.rb, line 193
    193:       def rename_table_sql(name, new_name)
    194:         "sp_rename #{literal(quote_schema_table(name))}, #{quote_identifier(schema_and_table(new_name).pop)}"
    195:       end

rollback_savepoint_sql(depth) click to toggle source

SQL to rollback to a savepoint

         # File lib/sequel/adapters/shared/mssql.rb, line 198
    198:       def rollback_savepoint_sql(depth)
    199:         SQL_ROLLBACK_TO_SAVEPOINT % depth
    200:       end

rollback_transaction_sql() click to toggle source

SQL to ROLLBACK a transaction.

         # File lib/sequel/adapters/shared/mssql.rb, line 203
    203:       def rollback_transaction_sql
    204:         SQL_ROLLBACK
    205:       end

schema_column_type(db_type) click to toggle source

The closest MSSQL equivalent of a boolean datatype is the bit type.

         # File lib/sequel/adapters/shared/mssql.rb, line 208
    208:       def schema_column_type(db_type)
    209:         case db_type
    210:         when /\A(bit)\z/o
    211:           :boolean
    212:         else
    213:           super
    214:         end
    215:       end

schema_parse_table(table_name, opts) click to toggle source

MSSQL uses the INFORMATION_SCHEMA to hold column information, and parses primary key information from the sysindexes, sysindexkeys, and syscolumns system tables.

         # File lib/sequel/adapters/shared/mssql.rb, line 220
    220:       def schema_parse_table(table_name, opts)
    221:         m = output_identifier_meth(opts[:dataset])
    222:         m2 = input_identifier_meth(opts[:dataset])
    223:         tn = m2.call(table_name.to_s)
    224:         table_id = get{object_id(tn)}
    225:         pk_index_id = metadata_dataset.from(:sysindexes).
    226:           where(:id=>table_id, :indid=>1..254){{(status & 2048)=>2048}}.
    227:           get(:indid)
    228:         pk_cols = metadata_dataset.from(:sysindexkeys___sik).
    229:           join(:syscolumns___sc, :id=>:id, :colid=>:colid).
    230:           where(:sik__id=>table_id, :sik__indid=>pk_index_id).
    231:           select_order_map(:sc__name)
    232:         ds = metadata_dataset.from(:information_schema__tables___t).
    233:          join(:information_schema__columns___c, :table_catalog=>:table_catalog,
    234:               :table_schema => :table_schema, :table_name => :table_name).
    235:          select(:column_name___column, :data_type___db_type, :character_maximum_length___max_chars, :column_default___default, :is_nullable___allow_null, :numeric_precision___column_size, :numeric_scale___scale).
    236:          filter(:c__table_name=>tn)
    237:         if schema = opts[:schema] || default_schema
    238:           ds.filter!(:c__table_schema=>schema)
    239:         end
    240:         ds.map do |row|
    241:           row[:primary_key] = pk_cols.include?(row[:column])
    242:           row[:allow_null] = row[:allow_null] == 'YES' ? true : false
    243:           row[:default] = nil if blank_object?(row[:default])
    244:           row[:type] = if row[:db_type] =~ DECIMAL_TYPE_RE && row[:scale] == 0
    245:             :integer
    246:           else
    247:             schema_column_type(row[:db_type])
    248:           end
    249:           [m.call(row.delete(:column)), row]
    250:         end
    251:       end

set_mssql_unicode_strings() click to toggle source

Set the mssql_unicode_strings settings from the given options.

         # File lib/sequel/adapters/shared/mssql.rb, line 254
    254:       def set_mssql_unicode_strings
    255:         @mssql_unicode_strings = typecast_value_boolean(@opts.fetch(:mssql_unicode_strings, true))
    256:       end

type_literal_generic_datetime(column) click to toggle source

MSSQL has both datetime and timestamp classes, most people are going to want datetime

         # File lib/sequel/adapters/shared/mssql.rb, line 260
    260:       def type_literal_generic_datetime(column)
    261:         :datetime
    262:       end

type_literal_generic_file(column) click to toggle source

MSSQL uses varbinary(max) type for blobs

         # File lib/sequel/adapters/shared/mssql.rb, line 276
    276:       def type_literal_generic_file(column)
    277:         :'varbinary(max)'
    278:       end

type_literal_generic_time(column) click to toggle source

MSSQL has both datetime and timestamp classes, most people are going to want datetime

         # File lib/sequel/adapters/shared/mssql.rb, line 266
    266:       def type_literal_generic_time(column)
    267:         column[:only_time] ? :time : :datetime
    268:       end

type_literal_generic_trueclass(column) click to toggle source

MSSQL doesn’t have a true boolean class, so it uses bit

         # File lib/sequel/adapters/shared/mssql.rb, line 271
    271:       def type_literal_generic_trueclass(column)
    272:         :bit
    273:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.