zoukankan
html css js c++ java
Sqlserver中的一些技巧
获取一个SQLServer上的所有数据库信息 用存储过程 sp_databases
在查询分析其中执行命令exec sp_databases
结果:master
14464
NULL
model
1280
NULL
msdb
14336
NULL
Northwind
4352
NULL
pubs
2560
NULL
Store
1912
NULL
tempdb
8704
NULL
test
1272
NULL
获取一个数据库的所有表用存储过程 sp_tables
执行命令:
use
Northwind
exec
sp_tables 结果:
Northwind dbo sysusers SYSTEM
TABLE
NULL
Northwind dbo Categories
TABLE
NULL
Northwind dbo CustomerCustomerDemo
TABLE
NULL
Northwind dbo CustomerDemographics
TABLE
NULL
Northwind dbo Customers
TABLE
NULL
Northwind dbo dtproperties
TABLE
NULL
Northwind dbo Employees
TABLE
NULL
Northwind dbo EmployeeTerritories
TABLE
NULL
(
.)
获取一个表的列信息用存储过程sp_columns
运行exec sp_columns
'
Orders
'
(Orders为表名) 结果
Northwind dbo Orders OrderID
4
int
identity
10
4
0
10
0
NULL
NULL
4
NULL
NULL
1
NO
56
Northwind dbo Orders CustomerID
-
8
nchar
5
10
NULL
NULL
1
NULL
NULL
-
8
NULL
10
2
YES
39
Northwind dbo Orders EmployeeID
4
int
10
4
0
10
1
NULL
NULL
4
NULL
NULL
3
YES
38
Northwind dbo Orders OrderDate
11
datetime
23
16
3
NULL
1
NULL
NULL
9
3
NULL
4
YES
111
Northwind dbo Orders RequiredDate
11
datetime
23
16
3
NULL
1
NULL
NULL
9
3
NULL
5
YES
111
Northwind dbo Orders ShippedDate
11
datetime
23
16
3
NULL
1
NULL
NULL
9
3
NULL
6
YES
111
Northwind dbo Orders ShipVia
4
int
10
4
0
10
1
NULL
NULL
4
NULL
NULL
7
YES
38
Northwind dbo Orders Freight
3
money
19
21
4
10
1
NULL
(
0
)
3
NULL
NULL
8
YES
110
Northwind dbo Orders ShipName
-
9
nvarchar
40
80
NULL
NULL
1
NULL
NULL
-
9
NULL
80
9
YES
39
(
)
获取一个数据库的所有存储过程,可以用
select
*
from
sysobjects
where
type
=
'
p
'
执行所得结果:
CustOrdersDetail
789577851
P
1
0
1610612736
0
0
0
2000
-
08
-
06
01
:
34
:
52.513
CustOrdersOrders
805577908
P
1
0
1610612736
0
0
0
2000
-
08
-
06
01
:
34
:
52.733
CustOrderHist
821577965
P
1
0
1610612736
0
0
0
2000
-
08
-
06
01
:
34
:
52.967
SalesByCategory
837578022
P
1
0
1610612736
0
0
0
2000
-
08
-
06
01
:
34
:
53.200
(
)
sysobjects这个东西还有其他一些用法,具体可参照SQLServer连机帮助
在ADO.NET里面获取一个存储过程的参数信息:
SqlConnection connect
=
new SqlConnection(ConnectionString);
connect.
Open
();
SqlCommand sc
=
new SqlCommand("SalesByCategory", connect);
//
SalesByCategory 为Northwind数据库中的一个存储过程.
sc.CommandType
=
CommandType.StoredProcedure;
SqlCommandBuilder.DeriveParameters(sc);
foreach(SqlParameter param
in
sc.Parameters)
{
Console.WriteLine("Name:{
0
}, Size:{
1
}, Type:{
2
}, Value:{
3
},Direction:{
4
},
IsNull
:{
5
}", param.ParameterName, param.Size, param.DbType, param.Value, param.Direction, param.IsNullable);
}
查看全文
相关阅读:
Nginx 413 Request Entity Too Large
tp U函数 logs
div + css 边框 虚线
html+css判断各个IE浏览器版本
win7 cmd 常用命令
mysql 常用命令
ThinkPHP学习(二)理清ThinkPHP的目录结构及访问规则,创建第一个控制器
将字符串 由一个字符集 转成 另一个字符集 及 随机生成中文
Sublime Text 3 中实现编译C语言程序
C语言入门
原文地址:https://www.cnblogs.com/ghd258/p/260745.html
最新文章
AndroidStudio使用genymotion模拟器
easypermissions的基本使用
Error:Some file crunching failed, see logs for details
自定义属性使用
FTP配置多用户多目录多权限
KVM虚拟机使用NAT+iptables做端口映射
Centos7.3 搭建KVM 命令安装VM虚拟机
CentOS7 yum 安装配置 MySQL 5.7
第三章 内建容器 数组, 切片, map
网页分享链接和网页授权获取用户的信息
热门文章
二. 进制
一. 汇编概述
第二章 go指针
goLand快捷键---mac版本
go项目部署到linxu
第一章 go基础语法
go gRPC介绍, demo
go os.State类用法
thinkphp 表单令牌
php 常用加密函数
Copyright © 2011-2022 走看看