C#網頁版代碼生成器,還在更新中....以前修復過ASPNETPAGER分頁控件的網頁版存儲過程代碼生成器,學到了一種思維,替換字符串,因此有空就寫下了這個。僅供參考,本人水平還有待提高,寫這個完全是興趣,寫的不好的地方不要罵我就行,呵呵。
存儲過程代碼如下,參考MSSQL SERVER文檔。
存儲過程代碼
1
2 ALTER proc [dbo].[GetTablesFromDatabase]
3 @dataBaseName nvarchar(200)
4 as
5 declare @sql nvarchar(2000);
6 set @sql=SELECT TABLE_CATALOG as "數據庫", TABLE_SCHEMA as "表架構" , TABLE_NAME as "表名" ,TABLE_TYPE as "表類型" FROM INFORMATION_SCHEMA.TABLES
7 where TABLE_CATALOG=N+@dataBaseName+ order by TABLE_NAME ; --get the role !
8 --SELECT * FROM INFORMATION_SCHEMA.TABLES
9 --where TABLE_CATALOG=TestSub --get the schema from databse
10 exec(@sql);
11 print(@sql);
12
13 ALTER proc [dbo].[GetColumnsFromTable]
14 @dataBaseName nvarchar(200),
15 @tableName nvarchar(200)
16 as
17 declare @dataBase nvarchar(200);
18 set @dataBase=rtrim(@dataBaseName)+.INFORMATION_SCHEMA.COLUMNS;
19 declare @sql nvarchar(2000);
20 --set @sql=SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT
21 --FROM +@dataBaseName+.INFORMATION_SCHEMA.COLUMNS
22 --WHERE TABLE_NAME =N+@tableName+;
23 set @sql=SELECT TABLE_CATALOG as "數據庫", TABLE_SCHEMA as "表架構" , TABLE_NAME as "表名", COLUMN_NAME as "列名",DATA_TYPE as "列數據類型"
24 FROM +@dataBase
25 + WHERE TABLE_NAME =N+@tableName+