SSMS for beginner Part 1 to 10

Source: Internet
Author: User

Part 1 connecting to SQL Server using SSMS

Note That,ssms is a client tool and not the server by Itself,it are a developer machines connects to SQL server.

Part 2 Creating altering and dropping a database

You cannot drop a database, if it was currently in use you'll get an error stating. So, if other users is connected, you need to put the database in a single user node and then drop the Database.system data Base cannot be dropped.

Part 3 Creating and working with tables

For Example:add a foreignkey relation.

Table:student:id,genderid;

Gender:id,studentid;

Alter Table ADD Constraint STUDENT_GENDERID_FK FOREIGN KEY References Gender (ID)

Syntax:

Alter table foreign key table name add constraint foreign KEY constraint name

FOREIGN key (foreign key name) references primary table name (primary key name)

Note:foreign Keys is used to enforce (mandatory) database integrity (complete). In layman ' s terms (generally), A foreign key in one table points to A primary key in another table. The foreign KEY constraint prevents invalid data form being inserted into the foreign key column. The values that you enter into the foreign key column, have to is one of the values contained in the table it points to.

Part 4 Adding a DEFAULT constraint

Altering an existing column to add a DEFAULT constraint:

ALTER Table Table Name

ADD CONSTRAINT Constraint name

Default value for column name

Adding a new column with the default value, to an existing table:

ALTER Table Table Name

Whether the ADD column name data type allows NULL

CONSTRAINT Constraint name default defaults

Dropping a constraint:

ALTER Table Table Name

DROP CONSTRAINT Constraint name

Part 5 cascading referential integrity constraint

Part 6 Adding a CHECK constraint

Part 7 Identity Column in SQL Server

Part 8 What do I get the last generated identity column value in SQL Server

Part 9 Unique Key constraint

Part of Select statement in SQL Server

Select specific or all columns

SELECT * FROM table name

Select column name, column name ... from table name

Distinct rows

Select DISTINCT column name from table name

Filtering with WHERE clause (clause)

Wild Cards in SQL Server

Joining multiple conditions using and AND and OR operators

Sorting rows using order by

Selecting top N or Top n percentage of rows

SSMS for beginner Part 1 to 10

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.