Writing re runnable sql server scripts Part 66
Link for code samples used in the demo Link for csharp, dotnet basics, mvc and sql server video tutorial playlists What is a rerunnable sql script A rerunnable script is a script, that, when run more than, once will not throw errors. Let s understand writing rerunnable sql scripts with an example. To create a table tblEmployee in Sample database, we will write the following CREATE TABLE sql script. USE Sample Create table tblEmployee ( ID int identity primary key, Name nvarchar(100), Gender nvarchar(10), DateOfBirth DateTime ) When you run this script once, the table tblEmployee gets created without any errors. If you run the script again, you will get an error There is already an object named tblEmployee in the database. To make this script rerunnable 1. Check for the existence of the table 2. Create the table if it does not exist
|
|