如何在SQL中检查表名 [英] how to check tablename in sql
本文介绍了如何在SQL中检查表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在sql中检查表名
在输入正确的表名时,我有1个文本框和按钮,它必须显示表名,否则表名正确.
how to check tablename in sql
i have 1 textbox and button while i enter table name correct it have to show table name otherwise table name is in correct.
推荐答案
在您的计算机中检查以下查询的结果C#代码
check the result of below query in your C# code
SELECT * FROM sysobjects where xtype='u' AND name=@tablename
将@tablename替换为文本框中的值
如果找到,则将文本框值视为有效表名称,否则无效.
replace @tablename with value in textbox
if found then treat textbox value as valide table name other wise invalid.
使用此查询,您可以看到当前数据库中的表名(即,在web.config中定义的表名)
从 information_schema.columns
Hi,
using this query you can see tablenames in current database(ie the one defined in web.config)
Select table_name from information_schema.columns
同样,您可以在哪里找到克劳斯
Similarly you can make where claues
最佳解决方案
如果OBJECT_ID(``TempDb ..#tempBranchTripLRMIS'',``U'')不为空
--where TempDb ..#tempBranchTripLRMIS =您的表对象名称
Best Solution
IF OBJECT_ID(''TempDb..#tempBranchTripLRMIS'',''U'')IS NOT NULL
--where TempDb..#tempBranchTripLRMIS=Your table object name
这篇关于如何在SQL中检查表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文