获取SQL Server所有数据库名,表名,字段名
/*
* Source URL: http://jonsion.javaeye.com/blog/511584
*/
1. 获取所有数据库名
1> SELECT name from master..sysdatabases;
2> go
2. 获取所有表名
1> USE master
2> go
1> SELECT name from sysobjects WHERE type='U';
2> go
3. 获取所有字段名
1> SELECT name from syscolumns WHERE id=object_id('table_name');
相关文档:
/*------------------------------------------------------------------
-- Author : htl258(Tony)
-- Date : 2010-04-16 14:30:23
-- Version: Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
Jul 9 2008 14:43:34
&nb ......
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[f_convert]') and xtype in (N'FN', N'IF', N'TF'))&n ......
1.修改列
EXEC sp_rename 'TableName.ColumnName','NewColumName'
2.增加列
ALTER TABLE TableName ADD ColumnName int --Type In Here
3.删除列
ALTER TABLE TableName DROP Column ColumnName ......
--该表保存结果
create table c(c1 tinyint, c2 tinyint, c3 tinyint, c4 tinyint, c5 tinyint, c6 tinyint, c7 tinyint, c8 tinyint, c9 tinyint, c10 tinyint, c11 tinyint, c12 tinyint, c13 tinyint, c14 tinyint, c15 tinyint, c16 tinyint, c17 tinyint, c18 tinyint, c19 tinyint, c20 tinyint, c21 tinyint, c22 t ......
1.
SQL> desc gjh_a05 ;
Name Type Nullable Default Comments
----- ------------- -------- ------- --------
A0500 VARCHAR2(2) Y &nbs ......