When you are in need of transforming a number to have zeros prefixed, use the below query. In order to prefix with zeros, we need to convert the number to a varchar.
SELECT REPLACE(STR(n,x),' ','y')
STR function in SQL returns character data converted from numeric data. In the query, 'n' is the number to be transformed. 'x' is the number of chars to be returned and 'y' is the character to be prefixed with the number 'n' in order to make the specified length 'x'.
eg. SELECT REPLACE(STR(9,5),' ','0') will return "00009"
About the author
This article contains a SQL query which can be used to determine the total number of open/active connections in MS SQL Server. Also explains, how to solve the error "Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached."
Using a short query we can list all the tables in the database along with the number of records in each table.
This article provide one solution to achieve server side paging, sorting and filtering in SQL Server 2008.