Friday, January 25, 2013

Align Sql script in Any Database

Scenario:
Today , while i was working with a large Stored Procedure i felt need of a way to auto align in sql server.

Approach:
 I searched for same on internet and got to know there isn't any short-key provided by Microsoft Sql server. While searching for an add-in there wasnt anything suggested by microsoft site of community provided. At the and i decided to use one of online formater and i got to know http://www.dpriver.com/pp/sqlformat.htm . It is good enough to handle most of the things.

Steps to Use:
1. Visit Link http://www.dpriver.com/pp/sqlformat.htm
2. Select Database from dropdown MSSQL
3. Copy text of a valid T-SQL script (SP or Table) needed to be formated and paste on First Text Area.
4. Check default settings at right side of page (you can leave everything as it is ) . There is one thing defiantly required to change is value in last Textbox (80 to 500 in my case). otherwise it will break one statement into multiple lines.
5. Click on Format button (First button below Text Area).
6. There is output will be displayed on second (destination) TextArea.
7. Now you can Copy Text of this TextArea and paste on you SSMS querywindow and run.

 Thanks dpriver.com for providing us this tool.

Updated: 25/10/2013
http://poorsql.com/ is also a good formater of sql script and we can use it in both ways either online or through adding Add-in to Sql server (SSMS ) and it works with only Ctrl+K,Ctrl+F. we found that is a fast way to format sql scripts.

www.ssmstoolspack.com/‎‎  , SSMS tools pack provide us a large number of functionality including formatting, running
script on different database at once, to store script change history so we can retrieve previous version of our scripts. It also include Insert script generator tool,find data in database/Table/Views and so on.
But after doing all that it makes us to compromise with speed of SSMS while i was trying it my sqlserver hanged 3 times so preferred to go with "Poorsql" instead of "SSMS tool pack".



Happy Living...
Happy Concepts...
Happy Programming...


Sunday, January 20, 2013

Search records in database using dynamic number of parameters

Search records in database using dynamic number of parameters

Scenario :
In a search form if there are multiple fields available as search criteria and user can search on the basics of a single field or without fields or a set of criteria fields.And we are calling same SP by sending entire criteria without taking consideration what criteria user has selected. In this case SP is responsible to use optimize technique to provide result dataset. It becomes extremely important if searching is done on set of tables or large set of data.

Approaches:
So to resolve above issue we have 2 reproaches described below:
1. Create dynamic query based on criteria sent by user
2. Create SP to smart enough to handle Null or empty fields.

// under construction


Happy Living...
Happy Concepts...
Happy Programming...