All Projects → kevinmartintech → sp_CRUDGen

kevinmartintech / sp_CRUDGen

Licence: MIT License
sp_CRUDGen is a free open-source SQL Server stored procedure that generates stored procedures for you based on your tables and metadata like foreign keys and data types. The generated stored procedure code utilizes the SQL Server community best practices.

Programming Languages

TSQL
950 projects

Projects that are alternatives of or similar to sp CRUDGen

ksqlDB.RestApi.Client-DotNet
ksqlDb.RestApi.Client is a C# LINQ-enabled client API for issuing and consuming ksqlDB push queries and executing statements. SqlServer.Connector is a client API for consuming row-level table changes (CDC - Change Data Capture) from Sql Server databases with the Debezium connector streaming platform.
Stars: ✭ 44 (+18.92%)
Mutual labels:  sql-server
N-Tier-Architecture
This is a n-layer architecture based on Common web application architectures.
Stars: ✭ 105 (+183.78%)
Mutual labels:  sql-server
OrdersManagementSystem
Project demonstrates usage of Prism composition library, Material design library, SQL Server, Entity Framework in WPF application
Stars: ✭ 29 (-21.62%)
Mutual labels:  sql-server
SimpleSqlExec
Lightweight command-line utility to execute queries on SQL Server in place of SQLCMD
Stars: ✭ 20 (-45.95%)
Mutual labels:  sql-server
Peasy.NET-Samples
Showcases a middle tier built with peasy and consumed by multiple client consumers
Stars: ✭ 33 (-10.81%)
Mutual labels:  sql-server
algorithm-bootcamp-sql
Teaching materials for Algorithm Bootcamp: Database Systems.
Stars: ✭ 18 (-51.35%)
Mutual labels:  sql-server
myTickle
📅 A PowerShell and SQL Server-based reminder system
Stars: ✭ 20 (-45.95%)
Mutual labels:  sql-server
CEDS-IDS
The CEDS Integrated Data Store factors the entities and attributes of the CEDS Domain Entity Schema (DES) with standard technical syntax and 3rd normal form database normalization. The IDS Logical Model provides a standard framework for integration of P-20 data systems through a well-normalized “operational data store”. In a P-20 data system, th…
Stars: ✭ 29 (-21.62%)
Mutual labels:  sql-server
StoreCleanArchitecture-NET
This is a basic project to demonstrate an introduction about the implementation of Clean Architecture on .NET
Stars: ✭ 19 (-48.65%)
Mutual labels:  sql-server
PdoOne
It simplifies the use of PDO in PHP by adding three methods: a simple wrapper between PDO, a query builder and an ORM.
Stars: ✭ 93 (+151.35%)
Mutual labels:  sql-server
sync-client
SyncProxy javascript client with support for all major embedded databases (IndexedDB, SQLite, WebSQL, LokiJS...)
Stars: ✭ 30 (-18.92%)
Mutual labels:  sql-server
GeoJSON.Net.Contrib
Repository for all GeoJSON.Net *.Contrib projects
Stars: ✭ 31 (-16.22%)
Mutual labels:  sql-server
rbac-react-redux-aspnetcore
A starter template for creating JWT token from ASP.NET Core API project and applying that JWT token authentication on React application
Stars: ✭ 54 (+45.95%)
Mutual labels:  sql-server
SqlServer.Rules
SQL Server static code analysis rules for SSDT database projects
Stars: ✭ 20 (-45.95%)
Mutual labels:  sql-server
dba-database
Database containing DBA helper code and open source software.
Stars: ✭ 79 (+113.51%)
Mutual labels:  sql-server
mssql-restapi
A simple REST API for SQL Server, Azure SQL DB and Azure SQL DW using SMO on .NET Core 2.0
Stars: ✭ 33 (-10.81%)
Mutual labels:  sql-server
sql server
Development repository for the sql_server cookbook
Stars: ✭ 60 (+62.16%)
Mutual labels:  sql-server
docker-why
Quick example of using SQL Server and .NET Core on Linux, loading data using bash
Stars: ✭ 41 (+10.81%)
Mutual labels:  sql-server
SQLDBA-SSMS-Solution
This respository contains TSQL/PowerShell Scripts to resolve issues of SQL Servers
Stars: ✭ 21 (-43.24%)
Mutual labels:  sql-server
YelpDatasetSQL
Working with the Yelp Dataset in Azure SQL and SQL Server
Stars: ✭ 16 (-56.76%)
Mutual labels:  sql-server

sp_CRUDGen

sp_CRUDGen is a free open-source SQL Server stored procedure that generates stored procedures for you based on your tables and metadata like foreign keys and data types. The generated stored procedure code utilizes the SQL Server community best practices.

You can use sp_CRUDGen to generate 11 different stored procedures from basic your Create, Read, Update, Delete, Upsert stored procedures to extremely advanced safe dynamic Search stored procedures otherwise known as optional parameters, kitchen sink, Swiss army knife, catch-all queries.

View articles and videos on the kevinmartin.tech website.

sp_CRUDGen will auto-generate and regenerate stored procedures for you. If you want to customize one of the generated stored procedures you can remove <auto-generated> comment section and the stored procedure will not be overwritten.

Install and execute sp_CRUDGen in the user database and not master.

The runtime depends on the complexity of your table structure.

Fork the repo to change the T-SQL style (or format with a tool like Redgate SQL Prompt) and naming conventions. Remember to create a pull request if you added something cool so the rest of the community can benefit.

Table names should be PascalCase for best table alias naming.

Use FOREIGN KEY REFERENCES between tables for ReadEager and Search to recurse over related tables.

There are paramaters you can set in sp_CRUDGen to customize for your column naming convention and stored procedure generations.

Parameter Name Description Default
@GenerateStoredProcedures 0 = Will only create the generated T-SQL to create the stored procedures, 1 = Will also create the stored procedures 0
@SchemaTableOrViewName NULL = Generate all tables & views, [SCHEMA.TABLEORVIEWNAME] or [TABLEORVIEWNAME] for just one table or view. NOTE: The leading column on the view should be the lowest grain primary key of the results. If there will be multiple contacts from a company returned in the results, ContactId should be the leading key on the view. If the view will only contain results for companies, then the leading column on the view should be CompanyId. NULL
     
@GenerateCreate 1 = Generate the Create stored procedure, 0 = Will not generate the Create stored procedure 1
@GenerateCreateMultiple 1 = Generate the Create stored procedure, 0 = Will not generate the Create stored procedure 1
@GenerateRead 1 = Generate the Read stored procedure, 0 = Will not generate the Read stored procedure 1
@GenerateReadEager 1 = Generate the ReadEager stored procedure, 0 = Will not generate the ReadEager stored procedure 1
@GenerateUpdate 1 = Generate the Update stored procedure, 0 = Will not generate the Update stored procedure 1
@GenerateUpdateMultiple 1 = Generate the Update stored procedure, 0 = Will not generate the Update stored procedure 1
@GenerateUpsert 1 = Generate the Upsert stored procedure, 0 = Will not generate the Upsert stored procedure 1
@GenerateIndate 1 = Generate the Indate stored procedure, 0 = Will not generate the Indate stored procedure 0
@GenerateDelete 1 = Generate the Delete stored procedure, 0 = Will not generate the Delete stored procedure 1
@GenerateDeleteMultiple 1 = Generate the DeleteMultiple stored procedure, 0 = Will not generate the DeleteMultiple stored procedure 1
@GenerateSearch 1 = Generate the Search stored procedure, 0 = Will not generate the Search stored procedure 1
@SearchSeparatorString Set this string to match your separator used when passing in a search parameter using the 'Between', 'BetweenWithBlanks', 'NotBetween', and 'NotBetweenWithBlanks' operators ' to '
     
@RowCreatePersonColumnName Is the column name used in your tables for the person who created a row. FOREIGN KEY REFERENCES to a Person table. RowCreatePersonId
@RowCreatePersonInclude 1 = Will generate table joins to the person table, 0 = Will not generate table joins to the person table 0
@RowCreateTimeColumnName Is the column name used in your tables to capture the datetime when the row was created. RowCreateTime
@RowCreateTimeFunction Is the system date function you want used in your tables for the @RowCreateTimeColumnName to capture when the row was created. {SYSDATETIMEOFFSET(), SYSUTCDATETIME(), SYSDATETIME(), GETUTCDATE(), GETDATE(), CURRENT_TIMESTAMP} SYSDATETIMEOFFSET()
     
@RowUpdatePersonColumnName Is the column name used in your tables for the person who updated a row. FOREIGN KEY REFERENCES to a Person table. RowUpdatePersonId
@RowUpdatePersonInclude 1 = Will generate table joins to the person table, 0 = Will not generate table joins to the person table 0
@RowUpdateTimeColumnName Is the column name used in your tables to capture the datetime when the row was last updated. RowUpdateTime
@RowUpdateTimeFunction Is the system date function you want used in your tables for the @RowUpdateTimeColumnName to capture when the row was updated. {SYSDATETIMEOFFSET(), SYSUTCDATETIME(), SYSDATETIME(), GETUTCDATE(), GETDATE(), CURRENT_TIMESTAMP} SYSDATETIMEOFFSET()
     
@RowVersionStampColumnName Is the column name in your tables for the rowversion/timestamp used for optimistic concurrency in the delete and update stored procedures. RowVersionStamp
     
@TemporalRowStartColumName Is the system-versioned temporal tables column name in your tables for the start period (GENERATED ALWAYS AS ROW START). This column will be ignored for inserts and deletes. RowValidFromTime
@TemporalRowEndColumName Is the system-versioned temporal tables column name in your tables for the end period (GENERATED ALWAYS AS ROW END). This column will be ignored for inserts and deletes. RowValidToTime
@ForceTemporalForView 1 = Forces the view to allow temporal functionality, 0 = The view will not allow temporal functionality 0
     
@VersionCheckMode 1 = Will only return the version number and not execute, 0 = Will execute this stored procedure 0

The Search stored procedure does not work with every column data type.

If you use extended properties description names on tables and columns they will be included as comments in the stored procedures.

Do not use SQL Server reserved keywords in object names.

Runs on SQL Server 2016, 2017, 2019, Azure SQL Server. JSON support can be changed to XML for 2014 and lower.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].