C # webpage Code Generator

Source: Internet
Author: User
Tags mssql server

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 +
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.