The following line could be added to the above script, so that, the CREATE TABLE script will only run if the table doesn’t already exist in the database (or a table with the same name): IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='Status' AND xtype='U') Only Run if the Table Doesn’t Already Exist When creating database objects, it’s good practice to check to see whether the object already exists or not. This prevents errors occurring when the script tries to create a table that is already in the database. ![]() You could just as easily run a script that creates a whole database, with all its objects and data and permissions all in one go. This is a basic script that only creates one small table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |