564 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Using T-SQL to create tables programmatically Part two of a four-part series of blogs |
---|
SQL doesn’t just select data; you can also use it to create tables and link them together with relationships. This blog shows you how!
This blog is part of a much longer tutorial on programming in SQL. Alternatively, have a look at our classroom-based training courses in SQL.
|
Tables that you create have to belong in a database, and you can create one of these in SQL. The command is:
So if you were creating a database to hold books and authors, you might run:
-- create a new database
CREATE DATABASE Literature
As always with SQL, you have to be careful to refresh your server in order to be able to see your new database:
![]() |
![]() |
Right-click on Databases ... | ... to show your new one. |
You can also delete any existing database before creating a new one, to make sure you start with a clean slate:
-- try to delete the database
BEGIN TRY
DROP DATABASE Literature
END TRY
BEGIN CATCH
END CATCH
-- now create a new database
CREATE DATABASE Literature
Now that we've got a database, it's time to create a new table in it!
Parts of this blog |
---|
|
Some other pages relevant to the above blogs include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2023. All Rights Reserved.