Sqlserver2005 Sqlcmd查看数据库表字段的命令

Sqlserver2005 Sqlcmd查看数据库表字段的命令,第1张

概述Sqlcmd是sqlserver自带的命令行工具,可以在不打开企业管理器的时候访问本地或者远程的数据库,对数据库进行管理。 Sqlcmd连接数据库:sqlcmd -S 10.78.1.99 -U sa -P sa C:/Users/1232>sqlcmd -S 10.78.1.99 -U sa -P sa 1>   1.查询数据库 select name from master.dbo.sysda

sqlcmd是sqlserver自带的命令行工具,可以在不打开企业管理器的时候访问本地或者远程的数据库,对数据库进行管理。

sqlcmd连接数据库:sqlcmd -S 10.78.1.99 -U sa -P sa

C:/Users/1232>sqlcmd -S 10.78.1.99 -U sa -P sa
1>

 

1.查询数据库
select name from master.dbo.sysdatabases

1> select name from master.dbo.sysdatabases
2> go
name
---------------------------------------------------------
master
tempdb
model
msdb
pubs
northwind
COMMON_Security
FlowEng
LTS
SUNDB
UTL
(11 行受影响)

 

2.查询数据库中的表
select name from sysobjects where xtype='U'

1> use master
2> go
已将数据库上下文改为 'master'。
1> select name from sysobjects where xtype='U'
2> go
name
------------------------------------------------------
spt_monitor
spt_values
spt_fallback_db
spt_fallback_dev
spt_fallback_usg
dtpropertIEs
spt_provIDer_types
aofax_send_task
aofax_recv_task
FAXRECV
Pboc
spt_datatype_info_ext
MSreplication_options
spt_datatype_info
spt_server_info

(15 行受影响)


3.查询表中的列
select c.name,c.length from syscolumns c inner join sysobjects t on c.ID = t.ID and t.name='spt_monitor'

1> select c.name,c.length from syscolumns c inner join sysobjects t on c.ID = t.ID and t.name='spt_monitor'
2> go
name                                                                                                                             length
-------------------------------------------------------------------------------------------------------------------------------- ------
lastrun                                                                                                                               8
cpu_busy                                                                                                                              4
io_busy                                                                                                                               4
IDle                                                                                                                                  4
pack_received                                                                                                                         4
pack_sent                                                                                                                             4
connections                                                                                                                           4
pack_errors                                                                                                                           4
total_read                                                                                                                            4
total_write                                                                                                                           4
total_errors                                                                                                                          4

(11 行受影响)

 

至于怎么打印出表字段的类型这个可以连查systypes表。

总结

以上是内存溢出为你收集整理的Sqlserver2005 Sqlcmd查看数据库/表/字段的命令全部内容,希望文章能够帮你解决Sqlserver2005 Sqlcmd查看数据库/表/字段的命令所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1181255.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存