根据字段值,查找数据表,用select查找和表的某一字段的值一样的数据表
比如水果字段有个值叫苹果查找叫苹果的数据表
--------------------编程问答-------------------- select * from tablename where 水果 = '苹果' --------------------编程问答-------------------- USE 数据库名;
GO
declare s varchar(20);
set s = "苹果";
IF OBJECT_ID (N'dbo.'+s, N'T') IS NOT NULL
select * from 苹果
GO
--------------------编程问答-------------------- declare cnt int;
set cnt = 0;
select cnt = count(*) from table
where 水果 = '苹果';
if(cnt >0)
begin
DECLARE @db_id int;
DECLARE @object_id int;
SET @db_id = DB_ID(N'数据库名');
SET @object_id = OBJECT_ID(N'数据库名.苹果');
IF @db_id IS NULL
BEGIN;
PRINT N'Invalid database';
END;
ELSE IF @object_id IS NULL
BEGIN;
PRINT N'Invalid object';
END;
ELSE
BEGIN;
SELECT * FROM sys.dm_db_index_operational_stats(@db_id, @object_id, NULL, NULL);
end
end
补充:.NET技术 , C#