It is very interesting how to insert multiple values with a single statement. Lets understand this with the help of below example. Suppose you have a Country table and you want to insert seed (initial values) then you can write those statement like below Now same values can be inserted with another one …
In this tip we will understand how to attach a database. I took Adventureworks2012 database Mdf file which we need to attach. Now do follow steps 1) Open the sql server and right click on Database folder of object explorer window. When you right click you will get a menu as shown below 2) …
To open SQL Profiler (right now I am talking about SQL Server 2012) you need to write Profiler.exe on run command as shown in below figure for earlier version you can use profiler90.exe. You can find various parameters option using Profiler.exe –? command When you run this command you will find below screen. Although …
It is just a simple tip nothing fancy. On command prompt you just type SSMS and hit OK. Your SQL server Management studio will be open. You can get other option also by typing ssms/? . You will get below options Now if you want to login to particular SQL Server Instance you can choose …
Sometimes some small things which we ignore can impact more. By default when you run any statement you will see in the message like no of records affected.As shown in below figure. Although, most of the time we do not require such information but still it is overhead. So to stop such overhead which impact …
We can determine date with different option in SQL server Option 1:– with GETDATE() we can get current date & time Go SELECT GETDATE()GO Option 2:- With sysDateTime() , we can get current date & time (with nano seconds)GO SELECT SYSDATETIME()GOOption 3:- with SYSDATETIMEOFFSET() , We can get current date & time with timezone offsetGo …
Sometime we require to know when we have taken last backup. So let me share here all the backup, log shipping related detail you can find in the MSDB database which is system database.SQL server maintain all the backup related detail in the MSDB database table As Show in the figure Now we can run …
b In last TIP tip#13, We learn how to find last updated statistics status. Now we know when it last updated so it may be require we need to update statistics for some of table. So to update statistics we need to write following command ( if we want to update statistics of entire tables …
When we are keen to know that what is currently running on SQL SERVER for analysis purpose then with the help of below SQL statement we can easily find those statements, Stored procedure, status etc. GoSELECT [Spid] = session_Id, ecid, [Database] = DB_NAME(sp.dbid), [User] = nt_username, [Status] = er.status, [Wait] = wait_type, [Individual Query] = …
As we mention in TIP 10 to set database user as Single user now to make this available again for all the user or multi user we need to do following ALTER DATABASE FriendsDBSET MULTI_USER WITH NO_WAIT; GO Here when we run above command FriendsDB again changed to MULTI USER. Here NO_WAIT means not …