Summary of some common SQL Server knowledge

Source: Internet
Author: User
Tags testlink

I usually work in Oracle for a while, and I am confused about SQL Server. In order to avoid further blurring, I took some time today to sort out some of my commonly used SQL Server and send it out, I forgot to come and try again in a few days. There is no technical content.

1. SQLserver forgot password modification method

Connect to SQL Server with "Windows Authentication" from "query analyzer" and execute the following process:

EXEC sp_password NULL, ''Your new password '', ''username, for example, sa''

2. Change the owner of objects in the current database.

EXEC sp_changeobjectowner ''dbo. Object name, for example, table name'' and ''new owner''

3. Distributed Query between SQLSERVER and SQLSERVER

Establish a connection server
Exec sp_addmediaserver ''testlink '', '''', '''sqloledb'', ''ip address of the remote database''

Create a ing between remote logins on the linked server
Exec sp_add1_srvlogin ''testlink '', ''false'', null, ''S'', ''password''

Query example
Select * from TESTLINK. Database name. dbo. Table name

4. View all tables in the database

Create view dbo. ALL_TABLES
AS
SELECT top 100 PERCENT a. ID,
Case when a. colorder = 1 THEN d. name ELSE ''' end as TableName,
Case when a. colorder = 1 THEN isnull (f. value, ''') ELSE ''' end as table description,
A. colorder AS field No., a. name AS field name,
ISNULL (g. [value], ''') AS field description, case when columnproperty (a. id,
A. name, ''isidentifi'') = 1 then'' & radic; ''else' ''' end as id,
CASE WHEN EXISTS
(SELECT 1
FROM dbo. sysindexes si INNER JOIN
Dbo. sysindexkeys sik ON si. id = sik. id AND si. indid = sik. indid INNER JOIN
Dbo. syscolumns SC ON SC. id = sik. id AND SC. colid = sik. colid INNER JOIN
Dbo. sysobjects so ON so. name = si. name AND so. xtype = ''pk''
WHERE SC. id = a. id AND SC. colid = a. colid) then'' & radic; ''else' ''' END AS primary key,
B. name AS type, a. length AS length, COLUMNPROPERTY (a. id, a. name, ''precision '')
AS precision, ISNULL (COLUMNPROPERTY (a. id, a. name, ''scal''), 0) AS decimal places,</

Related Article

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.