Posts tagged: SQL

Compare two tables record (SQL Server)

By Ashish Khandelwal, July 15, 2011

Sometime we want to compare the records between two database tables. These databases could be on same server or on different servers. Here is some information about how we can compare records between two tables. Hope this will help and give you some information.

The ‘EXCEPT’ operator performs the compare between two tables:

When both databases are on same server:

The following query returns any distinct values from the query to the left of the EXCEPT operand that are not also found on the right query.

SELECT ProductID

FROM Production.Product

EXCEPT

SELECT ProductID

FROM Production.WorkOrder ;

–Result: 266 Rows (products without work orders)

Read more »

SQL Query to the remote SQL server

By Ashish Khandelwal, September 25, 2009

Sometimes you want to query to the remote SQL server (Server which is in network). Following statement will help you to fire a query to the remote server:

Select * from [ServerName].[DatabaseName].[Scheme].[TableName]

Before you fire query, you are required to link to the server on which you want to query.  The ‘sp_addlinkedserver’is a system store procedure which can be used to add a link server to the server you are sitting.

EXEC sp_addlinkedserver

@server = ‘SourceServer’

, @Srvproduct = ”

, @Provider = ‘SQLNCLI’

, @datasrc = ‘Remote SQL Server instance name’ Read more »

SQL Server 2005 Performance Dashboard Reports

By Ashish Khandelwal, September 7, 2009

The SQL Server 2005 Performance Dashboard Reports are Reporting Services report files designed to be used with the Custom Reports feature introduced in the SQL Server 2005 SP2 release of SQL Server Management Studio. The reports allow a database administrator to quickly identify whether there is a current bottleneck on their system, and if a bottleneck is present, capture additional diagnostic data that may be necessary to resolve the problem. For example, if the system is experiencing waits for disk IO the dashboard allows the user to quickly see which sessions are performing the most IO, what query is running on each session and the query plan for each statement. Read more »

SQL Server Performance Tuning Tips for Stored Procedures

By Ashish Khandelwal, July 29, 2009

Whenever a client application needs to send Transact-SQL to SQL Server, send it in the form of a stored procedure instead of a script or embedded Transact-SQL. Stored procedures offer many benefits, including:  Read more »