C # The webpage version code generator is still being updated .... previously, I fixed the ASPNETPAGER paging control's webpage-based Stored Procedure Code Generator. I learned how to replace strings, so I wrote this when I was free. For reference only, I still need to improve my level. Writing this is totally an interest. Do not scold me if it is not easy to write.
The Stored Procedure Code is as follows. For more information, see the mssql server documentation.
Stored Procedure Code 1
2 ALTER proc [dbo]. [GetTablesFromDatabase]
3 @ dataBaseName nvarchar (200)
4
5 declare @ SQL nvarchar (2000 );
6 set @ SQL = SELECT TABLE_CATALOG as "Database", TABLE_SCHEMA as "Table schema", TABLE_NAME as "table name", TABLE_TYPE as "Table type" 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
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 "Database", TABLE_SCHEMA as "Table schema", TABLE_NAME as "table name", COLUMN_NAME as "column name", DATA_TYPE as "column data type"
24 FROM + @ dataBase
25 + WHERE TABLE_NAME = N + @ tableName +