private static bool TableExists(string tableName, DataAccessBaseEx dba) { var cmd = $@"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = '{tableName}'"; var num = dba.ExecuteScalar(cmd); return(num != 0); }
private static bool ColumnExists(string tableName, string columnName, DataAccessBaseEx dba) { var cmd = $@"SELECT 1 FROM sys.columns WHERE Name = '{columnName}' AND Object_ID = Object_ID(N'dbo.[{tableName}]')"; var num = dba.ExecuteScalar(cmd); return(num != 0); }
private static bool SuggestionsTableIndexExists(DataAccessBaseEx dba) { var indexCheck = $@"SELECT COUNT(*) FROM sys.indexes WHERE name='NotFoundRequests_ID' AND object_id = OBJECT_ID('[dbo].[BVN.NotFoundRequests]')"; var num = dba.ExecuteScalar(indexCheck); return(num != 0); }