|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Determining field type CHAR vs VARCHARIs there a way to programmatically determine if a SQL Server field is
of type CHAR vs. VARCHAR? I'm able to use the DataColumn.DataType property to determine that a field is a string, and to retrieve its max length. As far as I can tell, however, both CHAR and VARCHAR fields look the same when using the DataColumn object. This for a stored procedure code generator that is complete except for this one feature. TIA Jared You can query the sql server system tables to find out. Try looking at
syscolumns. Show quote "Jared" <goo***@tripletreesoftware.com> wrote in message news:1152821579.889154.28430@p79g2000cwp.googlegroups.com... > Is there a way to programmatically determine if a SQL Server field is > of type CHAR vs. VARCHAR? > > I'm able to use the DataColumn.DataType property to determine that a > field is a string, and to retrieve its max length. As far as I can > tell, however, both CHAR and VARCHAR fields look the same when using > the DataColumn object. > > This for a stored procedure code generator that is complete except for > this one feature. > > TIA > Jared > Hi Marina,
I was hoping this would be exposed in DataColumn, but querying the system tables should work, too. Thanks for your quick response! Jared Marina Levit [MVP] wrote: Show quote > You can query the sql server system tables to find out. Try looking at > syscolumns. > Bear in mind that the DataSet and the actual table within SQL are very
different things - a DataTable is not an SQL table, it just so happens that you can fill a DataTable from an SQL table - therefore the DataTable column types aren't the same as the SQL column types and the DataTable attributes don't neccessarily represent the associated SQL table. You'll see the same problem with default values in SQL tables - they aren't represented in the associated DataTable at all. -- Show quoteBest regards Mark Baldwin "Jared" <goo***@tripletreesoftware.com> wrote in message news:1152830097.676054.120200@p79g2000cwp.googlegroups.com... > Hi Marina, > > I was hoping this would be exposed in DataColumn, but querying the > system tables should work, too. Thanks for your quick response! > > Jared > > Marina Levit [MVP] wrote: >> You can query the sql server system tables to find out. Try looking at >> syscolumns. >> > |
|||||||||||||||||||||||