Several tips for improving the efficiency of SQL Server programmers

Source: Internet
Author: User
SQL Server Program Users often need to write T-SQL in SSMs (SQL Server Management studio) or query analyzer (before 2000) Code . The following skills can improve work efficiency.

The following describes ss2005 as an example, and ss2008 also applies. SS2000 may partially apply.

1. Shortcut Keys

As long as you are not a newbie, we all know that Ctrl + C/Ctrl + V, and no one will use the menu to copy/paste. For programmers who rely on computers to eat, it is not enough to know the two shortcut keys.

Using shortcut keys can save you time to search for icons or menus with the mouse. Which of the following statuses isFull keyboard operationIt saves time to move your hands to the mouse (UNIX programmers do this ).

Select a food order in SSMs:Tools> Custom, Select "Display Shortcut Keys in the screen prompt". In this way, when you hover the mouse over the execution icon, F5 is displayed. The shortcut key does not need to be memorized. When you click the mouse, you can use it next time.

You can refer to this post to query all keyboard shortcuts provided by the analyzer.

2. Custom shortcuts

SQL Server Management Studio supports custom shortcuts:Tool> Option> keyboard:
Among them, ALT + F1, CTRL + 1, CTRL + 2 are pre-defined shortcut keys.
Double-click the table name (or press Ctrl to click the table name) and select a table name, such as tablename. Pressing Alt + F1 is equivalent to executing "sp_help tablename" to view the description of the object.

The following are some custom shortcut keys I have added:
[Code = SQL]
-- Ctrl + F1: displays the first 100 rows of a table or view. Press Ctrl + F1 to select "tablename, 1000" to display the first 1000 rows of the table.
Sp_executesql n' if object_id (@ tablename) is not null exec (n'select top (''+ @ n + N') * From'' + @ tablename )', n' @ tablename nvarchar (100), @ n Int = 100 ',
-- Ctrl + 3: displays the view, stored procedure, function, and trigger definition scripts.
Sp_helptext
-- Ctrl + 4: displays the number of rows and occupied space of the table.
Sp_spaceused
-- Ctrl + 5: displays the space occupied by each index in the table.
Sp_executesql n' select index_name = ind. name, DDPs. used_page_count, DDPs. reserved_page_count, DDPs. row_count from sys. indexes ind inner join sys. dm_db_partition_stats DDPs on ind. object_id = DDPs. object_id and ind. index_id = DDPs. index_id where ind. object_id = object_id (@ tablename) ', n' @ tablename nvarchar (100 )',
-- Ctrl + 9: Field Names of the display table or view, separated by commas.
Sp_executesql n' select columns = stuff (select '','' + name from sys. columns where object_id = object_id (@ tablename) for XML Path ('''), 1, 2, ''') ', n' @ tablename nvarchar (100 )',
-- Ctrl + 0: Search for tables, views, stored procedures, and functions in the current database based on the selected keywords.
Sp_executesql n' select * From sys. objects where type in (''u'', ''v'', ''p'', ''fn '') and name like ''%'' + @ keyword + ''%'' order by type, name', n' @ keyword nvarchar (50 )',

[/Code]

 

reproduced from http://topic.csdn.net/u/20100625/14/f03d6c40-46c6-49f3-9cd2-92d79f1162c4.html

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.