结果不正确. sql server数据库中的表中的列数 [英] Incorrect Results in finding the no. of Columns in a table in sql server database

查看:77
本文介绍了结果不正确. sql server数据库中的表中的列数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题

当我数着数的时候表中的列数我将查询写为

I have the following problems

while I am Counting the no. of columns in a table I wrote the query as

select count(*)[No.OF Columns]  from information_schema.columns where table_name=''<table_name>'' </table_name>



运行正常,但是当我写< dbo.table_name>代替< table_name>

< table_name>
由于数据库表的存储方式,列数正变为0.
为什么?



It is running fine but when I write <dbo.table_name> instead of <table_name>

no of columns is becoming 0 as the database tables are stored like dbo.<table_name>

why?

推荐答案

dbo表示数据库对象.它是所有ur对象的前缀.它不是您的表名的一部分.

你应该像下面这样写
dbo means database object.. it is a prefix to all ur objects. it is not a part ur table name.

u should write like below
select count(*)[No.OF Columns]  from information_schema.columns
where table_name='tableName'



插入



insted

select count(*)[No.OF Columns]  from information_schema.columns
where table_name='dbo.tablename'


dbo是所有者前缀,它不是表名的一部分.
The dbo is the owner prefix it is not part of the table name.


这篇关于结果不正确. sql server数据库中的表中的列数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆