Creating a table in SQL Server

Use this example to see the core idea, then work through the complete steps below. Code snippets are Classic ASP / VBScript or SQL Server T-SQL as labelled, not PHP.

Create a table with a primary key

SQL example

CREATE TABLE dbo.student (
  id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
  name VARCHAR(50) NOT NULL,
  class VARCHAR(20) NOT NULL,
  mark INT NOT NULL,
  sex VARCHAR(20) NULL
);

Run the DDL once in a development SQL Server database. The related SELECT tutorial uses the same dbo.student columns.

On this page — Show page sectionsHide page sections

The historical version of this page showed SQL Server Enterprise Manager. That interface is obsolete, but the underlying task—creating a table—is still fundamental. Current SQL Server installations are commonly administered with SQL Server Management Studio (SSMS), Azure Data Studio replacements/tooling, or SQL scripts.

Create the table with T-SQL

CREATE TABLE dbo.student (
  id INT IDENTITY(1,1) NOT NULL CONSTRAINT PK_student PRIMARY KEY,
  name VARCHAR(50) NOT NULL,
  class VARCHAR(20) NOT NULL,
  mark INT NOT NULL,
  sex VARCHAR(20) NULL
);

An IDENTITY column can generate numeric keys, while the primary-key constraint enforces uniqueness. Choose column lengths and nullability from the real data requirements rather than copying old sample widths.

Historical screenshot

The screenshot below is retained only to document the older Enterprise Manager workflow. Do not expect the current SQL Server management interface to match it.

Historical SQL Server Enterprise Manager create table screen

Check the schema before using other lessons

All SQL Server student-table examples in this cluster use dbo.student and columns id, name, class, mark, and sex. Create the table in a test database before running the query examples.

DDL safety

CREATE TABLE changes database structure. Run it once in a development database rather than automatically executing schema changes in public-facing ASP requests.

Frequently asked questions

Are these queries for SQL Server or Access?
The SQL pages use SQL Server T-SQL. Access has different date functions, identity behavior, and SQL syntax.
Can I execute these statements directly on a live database?
Start in a test database. INSERT, UPDATE, DELETE, DROP and CREATE change data or schema.
How should Classic ASP send input to a query?
Use an ADODB.Command with typed, ordered parameters and encode database values when writing HTML.

Back to top ↑


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer