Introduction
Developing an application from zero in record time and with the minimum functionalities is a great challenge today for developers. In the database, we need tools that help us develop faster and easier according to our needs. It helps us to build a simple skeleton to implement database objects faster to add logic as needed for the application. This code can be customized to add new functionalities.
Background
There are many tools for generating or creating code for SQL Server. Some are free to use while others are paid. However, these types of tools are limited in the sense that you can not modify or add new features according to your needs. For the development of our projects, the intention of this code is to enable you to build faster, easier, and integrate more functionalities as you need it.
The code generator for SQL Server is developed with Transact-SQL in DML (Data manipulation language). It does not depend on other software for its operation or obtaining SQL code, where you can modify or add new functionalities to the code for your needs and objectives, with the aim of developing a database object faster without wasted time. The code is generated by tables in this first version, the database objects that are generated are the following:
- Stored Procedures
- Create backup table or movements record table.
- Trigger to insert movement in the backup record table.
- Before inserting statement: Data as originally.
- After inserting statement: New data updated.
- Scripts to test the created objects.
- Test Insert statement in the main table.
- Test update statement in the main table.
- Test Delete statement to the main table.
- Test stored procedures Load and Select.
- Proof of stored procedure select with identity of the table is greater than zero.
- Proof Stored Procedure select of all rows with identity of the table is equal to zero.
-
Using the code
It is easy and simple to use the SQL Server code generator script, it does not imply making large configurations, because it is developed in Transact-SQL for SQL Server, with the following steps,
- Open an instance of “Microsoft SQL Server Management Studio” (SSMS).
- Open the .sql file: "Code generator script for SQL Server.sql".
- Enter the name of the "Database" where it contains the table to generate the desired code.
- Enter the name of the "Table".
- Optional, you can add "comments" or leave it empty.
- Click on the "F5" or "Execute" key, the SQL Server code generator script will be executed.
- Get a "result" to take the code snippet of interest for your work.
Points of interest
Working to improve the code and add new functionalities for the generator code for SQL Server.
Working on code generators for other databases, such as MySQL.
History
Code Generator for SQL Server - Version 1.1.0 - January 2020 - First version