Is there a way in .NET SqlClient to translate SqlType to actual SQL type declaration, like
SqlInt32 -> "int"
SqlGuid -> "uniqueidentifier"
SqlXml -> "xml"
SqlString -> "nvarchar(??)"
without doing it manually?
CLARIFICATION: I am trying to automatically refactor a number of SQL select statements, and I need to know what types do they return. I'm planning to do it by running following code:
using (var connection = new SqlConnection(SqlConnectionString))
{
connection.Open();
var command = connection.CreateCommand();
command.CommandText = sql;
var reader = command.ExecuteReader(CommandBehavior.SchemaOnly);
for (int i = 0; i < reader.FieldCount; ++i)
{
var type = reader.GetProviderSpecificFieldType(i);
... generate some sql code ...
}
}
So, once I got the type, I'm trying to generate some SQL code and use SqlTye returned in GetProviderSpecificFieldType, and I wanted to see if there's already a function I can use that will take SqlType and give me back the SQL declaration