Use T-SQL to create two table structures based on the following entities: Each t
ID: 3687460 • Letter: U
Question
Use T-SQL to create two table structures based on the following entities: Each table will have the two attributes indicated in the example above. The MACHINE_PRODUCT and BOOTH_PRODUCT will be character data type and the two price fields will be a money data type. Copy and paste the T-SQL table create statements into your assignment submission for this part of the assignment. Preceding your T-SQL create table statement use the following statements: use cis305; if object_id('dbo.booth', 'U') is not null drop table dbo.booth;...T-SQL create table statement use cis305; if object_id('dbo.MACHINE', 'U') is not null drop table dbo.MACHINE;...T-SQL create table statement What is the purpose of the if-drop statements?Explanation / Answer
What is the purpose of the if-drop statements?
object_id(): This method checks whether the table readily exists in the database, then drop it. This is used before creatign a new table, as, if the table already exists, that is with attributes other than what you want, the insert statement may produce unexpected results. To avoid this, this statement is used.
And this object_id is taking 2 parameters, the first one being the table name, and the second one specifies that the table is Usertable.
Usually, after this statement, now a fresh table will be created with the required attributes, then the data will be inserted accordingly.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.