May 18, 2008
| SET |
SELECT |
| Can assign the value of an expression to the variable |
Can assign the value of an expression to the variable |
| Cannot retrieve data from data source. It can only retrieve data from the expressions. |
Can retrieve data from data source and also uses other SELECT clauses (WHERE, FROM etc) |
| Use SET only when you want to assign value of a function result or constant to a variable |
Can use for both i.e. retrieve value of function result |
Example
–Variable declaration
DECLARE
@vName VARCHAR(10),
@vobject_id VARCHAR(30),
@vName1 VARCHAR(30);
–assigning a single value
SET @vName1=’Test Value’;
–Selecting and retrieving multiple values in a single select statement
SELECT
@vName=name,
@vobject_id=object_id
FROM
sys.objects
WHERE
name =’sysrowsetcolumns’
–printing the retrieved values
SELECT @vName1,@vName, @vobject_id
–By Harsh Shah
No Comments » |
Interview, SQL2005 |
Permalink
Posted by shahharsh
February 28, 2008
To change the SQL Server Authentication mode please follow the below steps
1. Logon to SQL Server and Right Click on the instance name (see in the below image) and select Properties.

2. You will see the Server Properties for the selected instance, Here you select Security page from the left side pane. Once you select the Security page you will get the option to change the Server Authentication mode.

No Comments » |
SQL2005, Security |
Permalink
Posted by shahharsh
February 24, 2008
EXEC xp_loginconfig ‘login mode’
Result:

No Comments » |
SQL2005, Security |
Permalink
Posted by shahharsh
February 9, 2008
To know the version of the SQL Server on your machine type follwoing statement in the SQL Server Management Studio
SELECT @@VERSION
Following is the result:
Microsoft SQL Server 2005 - 9.00.3054.00 (Intel X86) Mar 23 2007 16:28:52 Copyright (c) 1988-2005 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
No Comments » |
SQL2005 | Tagged: SQL2005 |
Permalink
Posted by shahharsh
February 9, 2008
SET STATISTICS TIME ON
Displays the number of milliseconds required to parse, compile and execute SQL statements.
EXAMPLE
USE Adventureworks
SET STATISTICS TIME ON
SELECT * FROM Production.Product
SET STATISTICS TIME OFF
Results: (You can view the results in the Message Pane i.e. next to Results Pane)
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 50 ms.
(504 row(s) affected)
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 668 ms
No Comments » |
SQL2005 |
Permalink
Posted by shahharsh