2.2.4.1.1 SqlParameter

SqlParameter: This complex type element defines the individual parameters that are associated with a query. When specified as part of the sqlbatchSoapIn WSDL message, this element represents an input parameter. The properties of the input parameter are defined by the various attributes and subelements that are associated with this element. When specified as part of the sqlbatchSoapOut WSDL message, this element represents an output parameter. The properties of the output parameter are defined by the various attributes and subelements that are associated with this element.

SqlParameter.name: This string type attribute MUST exist if a SqlParameter element is specified. This attribute is used to specify the name of the parameter. The value of this attribute is limited to 127 characters, which is one less than the maximum number of characters allowed in a SQL Server identifier; one character is reserved for the parameter name’s implied "@" character.

SqlParameter.sqlDbType: This enumeration simple type attribute can exist if a SqlParameter element is specified. This attribute is used to specify the SQL Server data type that the parameter value MUST be treated as by the server. The default value of this attribute is "NVarChar". The set of supported values is defined by the sqlDbTypeEnum simple type, which is documented in section 2.2.5.3.

SqlParameter.direction: This enumeration simple type attribute can exist if a SqlParameter element is specified. This attribute is used to specify the direction of the parameter. The default value of this attribute is "Input". The supported values are listed in the following table.

Value

Meaning

Input

This parameter is an input-only parameter. The server will not return any values for this parameter.

InputOutput

This parameter is an input and output parameter. The server will return a value for this parameter.

SqlParameter.maxLength: This long type attribute can exist if a SqlParameter element is specified. The default value of this attribute is "1". This attribute is used to specify the maximum length of the parameter defined by the following sqlDbType data types.

sqlDbType

Value range

Binary

0 – 8000

VarBinary

-1, 0 – 8000

Note: -1 denotes varbinary (max)

Char

0 – 8000

NChar

0 – 4000

NVarChar

-1, 0 – 4000

Note: -1 denotes nvarchar (max)

VarChar

-1, 0 – 8000

Note: -1 denotes varchar (max)

SqlParameter.precision: This unsigned byte type attribute can exist if a SqlParameter element is specified. The default value of this attribute is "18". This attribute is used to specify the precision of the parameter defined by the following sqlDbType data types.

sqlDbType

Value range

Decimal

0 – 38

Float

0 – 38

Money

0 – 3

Real

0 – 38

SmallMoney

0 – 3

SqlParameter.scale: This unsigned byte type attribute can exist if a SqlParameter element is specified. The default value of this attribute is "0". This attribute is used to specify the scale of the parameter that is defined by the following sqlDbType data types.

sqlDbType

Value range

Decimal

0 – 38

Float

0 – 38

Real

0 – 38

SqlParameter.clrTypeName: This string type attribute can exist if a SqlParameter element is specified. This attribute is used to specify the name of the common language runtime (CLR) data type for the parameter when the sqlDbType attribute has a value of "Udt". The default value of this attribute is an empty string (""). The set of supported values depends on the set of CLR user-defined type (UDT) values defined in the SQL Server instance. The full three-part name of the CLR UDT SHOULD be used when specifying this attribute value.

SqlParameter.sqlCompareOptions: This enumeration simple type attribute can exist if a SqlParameter element is specified. This attribute is used by SQL Server string data types to specify how character values are compared and sorted. The default value of this attribute is "Default", which defers to the setting defined by the connected server. The set of supported values is defined by the sqlCompareOptionsList simple type, described in section 2.2.5.1.

SqlParameter.localeId: This int type attribute can exist if a SqlParameter element is specified. This attribute is used to specify the collation of the parameter character value. The default value of this attribute is "-1". A value of "-1" tells the server to use the locale of the current database. For example, if the parameter is of data type varchar and the locale is specified as Japanese, the server converts the parameter’s XML character value to Japanese.

Note Specifying a localeId value that is different from the current database localeId might cause additional data conversions, depending on the query.

SqlParameter.sqlCollationVersion: This int type attribute can exist if a SqlParameter element is specified. This attribute is used by SQL Server string data types to specify the version of the collation. The default value of this attribute is "0".<2>

SqlParameter.sqlSortId: This int type attribute can exist if a SqlParameter element is specified. This attribute is used by SQL Server string data types to specify the SQL Server sort id. The default value of this attribute is "0". The set of supported values is defined by [MSDN-SQLCollation].

SqlParameter.xmlSchemaCollation: This string type attribute can exist if a SqlParameter element is specified. This attribute is used to specify the name of the XML schema collection of the parameter when the sqlDbType attribute has a value of "Xml". The default value of this attribute is empty string (""). The set of supported values depends on the set of XML schema collections defined in the SQL Server instance. The full three-part name of the XML schema collection SHOULD be used when specifying this attribute value.