Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does SqlDbType.Structured mean?

From msdn website I get the following:

A special data type for specifying structured data contained in table-valued parameters.

It seems my code works with it and without it (pushing table to DB using stored procedure).

Can someone explain what does it do - I didn't understand it from the definition.

like image 342
Zbun Avatar asked Jul 06 '15 15:07

Zbun


People also ask

What is SqlDbType structured?

A special data type for specifying structured data contained in table-valued parameters.

What is SqlDbType?

SqlDbType = dataType ; Specifies the SQL Server data type of the parameter, using the SqlDbType enumeration in the System. Data namespace. If this property is set, the value of the Parameter is converted to this type before it's passed to the data source. The default is a SqlDbType.

What is the purpose of SqlDbType enum?

Specifies SQL Server-specific data type of a field, property, for use in a System.

What is a TVP in SQL?

Table-valued parameters are declared by using user-defined table types. You can use table-valued parameters to send multiple rows of data to a Transact-SQL statement or a routine, such as a stored procedure or function, without creating a temporary table or many parameters.


1 Answers

In SQL Server, you can define stored procedures and you can pass tables as parameter. This is then called a table valued parameter.

When you are programming in C#, you can pass such a table-valued parameter to the database by using the SqlDbType.Structured constant.

This post shows an example: How to pass a table-value parameter

like image 51
SQL Police Avatar answered Sep 28 '22 08:09

SQL Police