14/02/2014 by Nitesh

How to Add User to SQL Server Database using Scripts

While development, we normally use SQL Server Management Studio for various operations. However, when the code goes in production, Management studio is not found and we need to Execute SQL Queries using sqlcmd tool. Very often, we use a separate user account to access the database used by our program. This post will explain you…

Continue Reading »

05/10/2013 by Nitesh

How to Count Work Days Between 2 Dates in SQL Server

Friends, This is a real quick post to explain how you can calculate the number of work days between 2 dates in SQL Server. This post considers the Workdays from Monday to Friday. In case you want the workdays from Monday to Saturday, read on. So, lets us write a function that will display the…

Continue Reading »

03/10/2013 by Nitesh

Solution: The WITH MOVE clause can be used to relocate one or more files

Friends, Today working with SQL Server I was trying to restore a DB from .bak file and got a strange error while restoring using the normal procedure. I was working on SQL Server 2008 R2 and the backup was from an old version making me think the problem may be because incorrect SQL versions. The…

Continue Reading »

03/09/2013 by Nitesh

Solution: Error: 26 – Error Locating Server/Instance Specified

Friends, This is a very common problem that we face while working with SQL (be it any version of SQL) and we always spend some time to figure out the exact issue. Every time we need to look int where should we start looking for the problem. This post lists the basic issues that can…

Continue Reading »

02/06/2013 by Nitesh

How to calculate age based on 2 dates in SQL Server

Dear Friends, Often working with SQL server, we need to calculate the difference between 2 dates. We can get this done easily by using the DATEDIFF() function. Sometimes, we also need to calculate the age of a person on a specific date in SQL Server. SQL Server does not provide a direct function to do…

Continue Reading »

1 2 3 4