Tuesday, June 23, 2009

SQL Order By clause - List specific values on the top of list

List Specific values on the top in the order by clause

List all the coutries from counties table order by CountryName, but if you need to have "United States" and "Germany" on the top of list.

select * from Countries Order by
CASE Name
WHEN 'United States' THEN 1
WHEN 'Germany' THEN 2
ELSE 100
END,
Name

Puneet Singla

Tuesday, June 9, 2009

Visual Studio shortkuts

Here are some Visual Studio shortcuts that helped me increase my coding speed.
Open Smart Tag: Ctrl + .
Open Smart Tag: Ctrl + .
Cycle Clipboard Ring: Ctrl + Shift + V
Go to Definition: F12
Go to Line: Ctrl + G
Vertical Block Selection: Alt + Mouse or Shift + Alt + Right Arrow
View Properties Window: F4 or Alt + Enter
Comment Selection: Ctrl + K, Ctrl + C
Uncomment Selection: Ctrl + K, Ctrl + U
Toggle Code / Design Views: F7
Incremental Search: Ctrl + I
View Object Browser: Ctrl + Alt + J
Delete Line: Ctrl + L or Shift + Delete
Add New Item to Project: Ctrl + Shift + A
Find All References: Shift + F12
The Rename Refactor: Ctrl + R, R
Find All References: Shift + F12
Format Document: Ctrl + K, Ctrl + D
View Task List: Ctrl + \, Ctrl + T
Find in Files: Ctrl + Shift + F
Toggle Outlining Expansion: Ctrl + M, Ctrl + M
Save Any Output Window: Ctrl + S
Build Solution: Ctrl + Shift + B Ctrl + Shift + V

Puneet Singla

Thursday, June 4, 2009

Javascript Modal Popup

Javascript Modal Popup

http://www.ericmmartin.com/simplemodal/

Agile Carousel: JQuery Carousel Plugin
http://www.5bosses.com/examples/agile_carousel/simple_example/carousel.html

100 Popular jQuery Examples, Plugins and Tutorials
http://www.templatelite.com/100-popular-jquery-plugins/


Spry Sliding Panels widget:

http://www.adobe.com/devnet/dreamweaver/articles/sliding_panel.html

See Sliding panel at techSmith
http://www.techsmith.com/camtasia.asp

Puneet Singla

SQL Server Useful System Stored Procedures

SQL Server Help: Useful System Stored Procedures


SQL Server provides a number of useful system stored procedures that allow you to determine information about the database itself. Note that if you have problems running any of these stored procedures, check that the user you're running them as actually has permissions to execute the stored procedure in question.

Find out which tables and views are in a database
This is simply achieved by making use of the sp_tables system stored procedure, i.e.

EXEC sp_tables

The returned results set contains a list of the tables (and views) in the current database. The TABLE_NAME column gives the name of the table. The TABLE_TYPE column indicates if the table is a TABLE, SYSTEM TABLE or a VIEW. The TABLE_OWNER column is also useful as it shows the table's owner.

Find out which columns are in a database table
This is achieved by making use of the sp_columns system stored procedure, passing in the table name as the parameter, i.e.

EXEC sp_columns 'sales'

The returned results set contains a list of the table's columns. There are quite a few columns in the results set, so only the most useful will be described here:

The COLUMN_NAME column gives the name of the column.
The TYPE_NAME column gives the column's data type.
The LENGTH column gives the column's data type length.
The IS_NULLABLE column shows whether the column accepts null values.

Programmatically display a View's Transact-SQL
The system stored procedure sp_helptext will return a results set containing the lines of Transact-SQL that comprise the View. For example, the following will return the text of the stored procedure Order Details Extended's CREATE VIEW statement:

EXEC sp_helptext 'Order Details Extended'

The text of the CREATE VIEW statement is contained within the Text column of the results set.

Find out which stored procedures are in a database
This is achieved by making use of the sp_stored_procedures system stored procedure,

EXEC sp_stored_procedures

The returned results set contains a list of the stored procedures in the database in which it is executed. in the results set, the PROCEDURE_NAME column gives the name of the stored procedure.

Programmatically display a stored procedure's Transact-SQL
The system stored procedure sp_helptext will return a results set containing the lines of Transact-SQL that comprise the stored procedure. For example, the following will return the text of the stored procedure CustOrdersDetail's CREATE PROCEDURE statement:

EXEC sp_helptext 'CustOrdersDetail'

The text is contained within the Text column of the results set.

Useful Links

Puneet Singla

Monday, June 1, 2009