If you watch any SQL Server Developer, you will notice one particular task them doing every day frequently. It is they select the row from the table to see what are the various kinds of data it contains. Most of the tables are very big so it is always advisable to retrieve only a single row from the table. It is very cumbersome for developers to continuously write following code to retrieve a single row to see what the table contains.
SELECT TOP 1 * FROM TableName
I suggest you try to write above code and there is good chance that one has to look at the keyboard to type above code as it requires numbers. Even expert typist often has to look at the keyboard when they have to deal with Special Symbole (in our case *) and number (in our case 1) when typing subsequently. The counter argument is to not use above command but use SP_HELP or any other SP which describes the schema of the table. Well, this may be a good idea but we developer like to do things our own way. Just to be clear it is never a good idea to do any development on production server.
There is a shortcut how we can make our life easier if we use SQL Server Management Studio Shortcut. You can see following image where I am configuring SSMS shortcut.
Go to SSMS Menu >> Tools >> Options >> Environment >> Keyboard >> Query Shortcuts.
Now on the right side click on the preferred shortcut (in this case I am selecting CTRL + 3) and now in the column of the Stored Procedure type following statement
SELECT TOP 1 * FROM
Pay special attention that I have not mentioned the name of the table. The syntax is incomplete as we will SELECT the name of the table later on of SSMS Query Editor.
Once that is done, now go to SSMS and select any preferred table name. While the table name is selected type CTRL + 3 and you will notice that the query will run and will return a single row as a resultset. Now developer just has to select the table name and click on CTRL + 3 or your preferred shortcut key and you will be able to see a single row from your table.
This trick can be very helpful when a developer is debugging a long stored procedure with lots of a table name or while writing complex query.
Reference: Pinal Dave (https://blog.sqlauthority.com)
Sir if we have two parameter in stored procedure and one page needed only one parameter then how to change in procedure so that there isno error
I need more information for it.
Sir, But what is we want to select only one column value ?
Select Top 1 from Table
something like that.
How it can be done ?