Skip to main content

Posts

What is VLF in SQL?

VLF  stand for virtual log file. Its the internal structure of log file. Virtual log file means while running (DBCC loginfo)it will shows the status 0 indicates Recoverable 1 indicates Active 2 indicates unused 3.indicates reused. The Tlog file internally divided into virtual log files. You can see how many vlfs you have in your log file can be find out by running dbcc loginfo. Too many vlfs will might slow down the db recovery. Each vlf will be having status 0 to 9. These status number indicates the current vlf's status i.e 0 reusable 1 waiting for log backup 2 Active and so on.

What is a minimal logged in SQL

1.Minimal information it writes in the log file, when databse in bulk model. 2.If transaction is minimally logged only enough information is logged in transaction log to rollback the transaction no information is logged to roll it forward. This is why you loose point in time recovery if operation is minimally logged.

What is difference between Single user mode and Offline mode om SQL

1.When database is in offline users cant connect we need to bring our database in to emergency mode to connect to db for this we will try to bring in single user mode so that we can able to connect with single user. 2.Single user mode means access only SA admin,offline mode means no one user can not access. 3.To bring the database online from offline,there is no need of putting it in emergency mode. 4.If  database  in single user mode it will allow only one connection, it is in offline we can't do any thing.

Total IPs Required for fail-over clustering in SQL

How many Total ip's required build win&SQL Failover clustering Active/Active & Active/Passive? Ans. In a 2 node cluster each ip for each node and one ip for win cluster and one for msdtc and one for each cluster group .. If u use private network for heartbeat then 2 more ip .. So total of 5-7 In a two node cluster 7ip's are needed two private ip's for connecting to quarum. one for node A and other for node B, two public ip's one for node A and other one For node B and one for msdic and one for msclust and one ip for switch for connecting to san drives in which data is stored.  Total 7ip's are needed.

Script to apply any user permission to the all databases of SQL

/* It is a new feature and it has ability to create user defined server roles and assign server level/scope permissions. */ /* - Following actions are performed to implement this new feature: - Created Server role - Created Login and made member of server role - Granted Standard view permission After completion above steps the login has ability to make connection any database with data reader permission. */ USE master GO CREATE SERVER ROLE ALLDBREADER Go CREATE LOGIN [DBREADER] WITH PASSWORD=N'123', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF GO ALTER SERVER ROLE ALLDBREADER ADD MEMBER [DBREADER] GO GRANT CONNECT SQL TO ALLDBREADER GRANT VIEW ANY DATABASE TO ALLDBREADER GRANT VIEW ANY DEFINITION TO ALLDBREADER GRANT VIEW SERVER STATE to ALLDBREADER GRANT CONTROL SERVER TO ALLDBREADER DENY SHUTDOWN TO ALLDBREADER Go USE master GO CREATE SERVER ROLE ALLDBREADER Go GRANT CONTROL SERVER TO ALLDBREADER DENY ALTER ANY DATABASE TO

Script or query for FAILED JOBS Details with error Messages in SQL

You can use following Script or query for FAILED JOBS Details with error Messages in SQL. I hope it will help you. USE Msdb Declare @lastRunDate int =replace(CAST(getdate()as date),'-','') SELECT Sj.name as JobName ,CASE SJH.run_status WHEN 0 THEN 'Failed' WHEN 1 THEN 'Succeded' WHEN 2 THEN 'Retry' WHEN 3 THEN 'Canceled' END AS JobStatus,SJH.message from sysjobhistory SJH inner join sysjobs SJ ON SJH.job_id = SJ.job_id where SJH.step_id = 0 and sjh.run_date =@lastRunDate and SJH.run_status =0

What is SQL Server Profile

SQL Server Profiler. It is a graphical based tool provided by SQL Server. It enables you to trace a query. For example.you have a SP which you wish to trace. you can execute the SP and start a profiler trace on it. It will show you row by row execution of the SP SQL Server Profiler is used to trace and analyze the SQL Server running processes and queries in the cases of performance issue. It is taken high memory so not used in main server. It is have so many events for trace. so your select desired event and filter it. It can use to find the blocking by applying trace and catch everythng runing on the server

How to Get historical data of blocked process in SQL

WITH [Blocking]AS (SELECT w.[session_id] ,s.[original_login_name] ,s.[login_name] ,w.[wait_duration_ms] ,r.[scheduler_id] ,w.[wait_type] ,r.[status] ,r.[wait_resource] ,w.[resource_description] ,s.[program_name] ,w.[blocking_session_id] ,s.[host_name] ,r.[command] ,r.[percent_complete] ,r.[cpu_time] ,r.[total_elapsed_time] ,r.[reads] ,r.[writes] ,r.[logical_reads] ,r.[row_count] ,q.[text] ,q.[dbid] ,p.[query_plan] ,r.[plan_handle] FROM [sys].[dm_os_waiting_tasks] w INNER JOIN [sys].[dm_exec_sessions] s ON w.[session_id] = s.[session_id] INNER JOIN [sys].[dm_exec_requests] r ON s.[session_id] = r.[session_id] CROSS APPLY [sys].[dm_exec_sql_text](r.[plan_handle]) q CROSS APPLY [sys].[dm_exec_query_plan](r.[plan_handle]) p WHERE w.[session_id] > 50 ) Insert into Blocking_v1 ([session_id] ,[blocking_session_id] ,[WaitingUserSessionLogin] ,[BlockingUserSessionLogin] ,[scheduler_id]

What is Covering Index in SQL

A covering index is a non-clustered index which includes all columns referenced in the query and therefore, the optimizer does not have to perform an additional look-up to the table in order to retrieve the data requested. As the data requested is all indexed by the covering index, it is a faster operation. covering index is a non-clustered index which stores additional columns at leaf level to avoid bookmark lookup to heap/clustered index.this is typically created using INCLUDE clause. Let say we have a table tab1 and we have columns starts from column 1 to 10. and we have clustered index on column1 and non clustered index on column 2 . for example you written a query select * from tab1 where column 2=200. this query first will go and look for the matching data in non clustered index and because of our query want to retrieve all the columns it will perform key look up , not helathy. this time i had one more non clustered index on column3 and column4 ,composite.in this case our query

Port in sql server

SQL server assign default port 1433 to default instance...for named instance it dynamically allots a port number, ideally it is five digit port number. To see port of SQL Server you can check as below. Go to configuration manager-->SQL Serve network Configuration-> Select instance-->right click TCP/IP properties-->IP Properties

Dedicated admin account in SQL

Dac means dedicared admin account, which is used to access sql server at .by default 1433 is sql server port , 1434 ia dac account. Starting the server in single user mode will use DAC (Dedicated Administrative Connection) connection. DAC Connection will use If the number of connections are limited for the instance and all are connected and if some one wants to connect and fails to troubleshoot if DBA want to connect he will also be restricted then he can use DAC connection to connect to the instance. When ever the SQL Server standard connection not establish the connection then we go with DAC connection . only sys admin can use this DAC to connect the server and troubleshoot the problems.

Interview questions for sql DBA

1.What are Differences in Delete & Truncate . 2.What are Differences in UNIQUE and Primary key ? 3. What are the agents involved in replication 4.Which Types of clusters and how many ips are required to install failover cluster? 5.Configuration of logshipping and DB mirroring. 5.What are Types of backups and backup scenario? 6.What is deadlock and blocking? 7.Differences between clustered and non clustered indexes? 8.Why SQL Server Agent is used? 9.What are Types of System databases 10.What are the steps for restoring a database?

what is linked server in sql server?

Linked server means to retrieve the data from the other server to connect our own instance, before configure the linked server we must know the target server login and password then only we access the data from the other server. Linked server means access the data from one server another server is called linked server. store procedure is sp_addlinkedserver. When we have to run the distributed transactions we need to linkup the servers internally we use linked servers concept.Here distributed transactions means A query which has to executed on multiple servers at a time is called distributed transactions.

Checkpoint and lazywrite in SQL

Checkpoint : Write all the dirty pages into buffer cache. It is not clear from buffer cache is called checkpoint.check point is the internal process which will take dirty blocks from buffer pool to data file on interval based. Lazywriter: Write all the dirty pages into buffer cache. It is clear from buffer cache is called lazywriter Checkpoint and lazywrite do the same job of flushing out the (8k size) pages from the memory to disk the only difference is of when they do this task. A lazy write does its task when there is resource contention and sql engine needs to process more pages and bring them in the memory. The lazy writer in this case gets all the pages which have been residing in the memory for the longest time and flushes them to the disk. A checkpoint on the other hand does the task for the SQL engine to create a stable point from which SQL can recover in case there is a failure of service during some processing. A checkpoint is not issued due to lack of resources. Please not

Grant Revoke privilege in SQL

Grant/Revoke are the keywords which uses to grant/revoke privileges on an object to/from a user/group. Grant is a keyword you use when you want to authorize/authenticate. a principal and Revoke is the Keyword used when you want to take back the Authorization/authentication from the Principal. Principal refers to Lo-gin at instance level.Database user at Database level. Grant,revoke,deny,with grant are object level security.Grant means giving permission on a particular object to user.Command: grant privilege on object name to username. Revoke means taking back the permission. Command: revoke privilege on object name from username. Deny means restrict user not to do something command: deny privilege on object name to username. With grant means by using grant user can give grant permission to other user command: grant privilege on object name to user with grant.

Clustered index and non clustered index in SQL

Clustered index which reordered the table and saved separately as index table(data pages stored as B-tree) there can be one clustered index per db & Non clustered index is typically a index(data pages stored as heap) A table can have only one clustered index with many non clustered indexes. The leaf nodes of the cluster index stores data pages and non clustered index stores key values(where as table includes clustered index) or rid's(table contains non cluster index only).

Advantage and disadvantage of Team Viewer , Ammy Admin and show my PC etc

Advantage of Team Viewer , Ammy Admin and show my PC etc You can share your desktop to other user or pc to take live support help from your friend or colleague. You can also help to other friends also. If you want to use limited hours in a month use of   Team Viewer , Ammy Admin and show my PC then you can use trial version but if you want to use lot of time in a single month then you need to buy license. You can buy license online. Disadvantage of Team Viewer , Ammy Admin and show my PC Mostly these type of connections registers all clicks and keypress, that means they can know about all your logins and passwords and you PC could be hacked or misused(Its possibility but mostly they do not do it).