This video is the beginning portion of a much larger video where I will cover how I used sql code to generate data for a puzzle book. In this particular video, I cover IF EXISTS, DROP TABLE, SELECT INTO, INSERT INTO, SYSOBJECTS, XTYPE, and certain errors that you will need to look out for.
Link to my SQL Courses on Udemy: https://www.udemy.com/course/sql-serv...
--------------------------------------------------------------------------
-- THIS WILL CRASH, IF THE TABLE DOES NOT EXIST
--------------------------------------------------------------------------
--IF EXISTS (SELECT * FROM A)
--DROP TABLE dbo.A
--------------------------------------------------------------------------
-- THIS WILL ALWAYS WORK
--------------------------------------------------------------------------
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'A' AND xtype = 'u')
DROP TABLE dbo.A
--------------------------------------------------------------------------
SELECT '1' A INTO A
INSERT INTO A SELECT '2'
INSERT INTO A SELECT '3'
INSERT INTO A SELECT '4'
INSERT INTO A SELECT '5'
INSERT INTO A SELECT '6'
SELECT * FROM A
Watch video IF EXISTS, DROP TABLE, SELECT INTO, INSERT INTO, SYSOBJECTS, XTYPE online without registration, duration hours minute second in high quality. This video was added by user SQL University 07 August 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 472 once and liked it 12 people.