PC Review


Reply
Thread Tools Rate Thread

Check if table has LOB columns

 
 
sjoshi
Guest
Posts: n/a
 
      6th Dec 2007
I need to check if a table in SQLServer 2005 is made up of one of the
LOB columns :image, ntext, text, varchar(max), nvarchar(max),
varbinary(max), and xml

Currently I'm using SMO with code like this...

private bool TableHasLOBColumns(ColumnCollection tableColns)
{
bool result = false;
foreach (Column cl in tableColns)
{
if (checkSQLTypes.Exists(delegate(SqlDataType match)
{
return match.Equals(cl.DataType.SqlDataType);
}))
{
result = true;
break;
}
} return result;
}

Where checkSQLTypes is defined as

private static List<SqlDataType> checkSQLTypes = new
List<SqlDataType>();

checkSQLTypes.AddRange(new SqlDataType[] { SqlDataType.Image,
SqlDataType.NText, SqlDataType.Text,
SqlDataType.NVarCharMax,
SqlDataType.VarCharMax, SqlDataType.VarBinaryMax, SqlDataType.Xml });

However I find the routine using SMO to be too slow especially when
one has 500+ tables to check. Is there a quicker/simpler way to do
this ??

thanks
Sunit
 
Reply With Quote
 
 
 
 
William Vaughn
Guest
Posts: n/a
 
      6th Dec 2007

I would experiment with the ADO.NET 2.0 GetSchema Connection class. It might
work better.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"sjoshi" <(E-Mail Removed)> wrote in message
news:4e5c2540-f9f4-4cd6-a9e6-(E-Mail Removed)...
>I need to check if a table in SQLServer 2005 is made up of one of the
> LOB columns :image, ntext, text, varchar(max), nvarchar(max),
> varbinary(max), and xml
>
> Currently I'm using SMO with code like this...
>
> private bool TableHasLOBColumns(ColumnCollection tableColns)
> {
> bool result = false;
> foreach (Column cl in tableColns)
> {
> if (checkSQLTypes.Exists(delegate(SqlDataType match)
> {
> return match.Equals(cl.DataType.SqlDataType);
> }))
> {
> result = true;
> break;
> }
> } return result;
> }
>
> Where checkSQLTypes is defined as
>
> private static List<SqlDataType> checkSQLTypes = new
> List<SqlDataType>();
>
> checkSQLTypes.AddRange(new SqlDataType[] { SqlDataType.Image,
> SqlDataType.NText, SqlDataType.Text,
> SqlDataType.NVarCharMax,
> SqlDataType.VarCharMax, SqlDataType.VarBinaryMax, SqlDataType.Xml });
>
> However I find the routine using SMO to be too slow especially when
> one has 500+ tables to check. Is there a quicker/simpler way to do
> this ??
>
> thanks
> Sunit


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make Columns A&B on Sheet2 always equal Sheet1 table columns A&B KnightBall Microsoft Excel Worksheet Functions 6 18th Aug 2009 05:48 PM
Make Columns A&B on Sheet2 always equal Sheet1 table columns A&B KnightBall Microsoft Excel Setup 6 18th Aug 2009 05:48 PM
Convert Columns to Rows and insert into another table based on valuesin columns Gurvinder Microsoft Access Form Coding 7 25th Nov 2008 10:03 PM
Convert Columns to Rows and insert into another table based on valuesin columns Gurvinder Microsoft Access Queries 0 24th Nov 2008 09:00 PM
Pivot Table Creating New Columns that Subtract Two Existing Columns den4673 Microsoft Excel Misc 3 17th Dec 2004 01:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:32 AM.