Thursday, August 28, 2014

C# To Check if Field Exists in SQL View

You can execute a sql query:



SELECT count(*) FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name ='FieldName'
and table_name = 'tablename';

What that will do is return 1 if there's one field= that name



Hope that helps

Please don't forget to up vote answers you like or which help you and mark one(s) which answer your question.



No comments:

Post a Comment