10 October, 2020
Ans: Yes! Adding CPUs can occur physically by adding new hardware, logically by online hardware partitioning, or virtually through a virtualization layer. Starting with SQL Server 2008, SQL Server supports hot-add CPU.
Ans: Single User Mode (-m) : sqlcmd –m –d master –S PAXT3DEVSQL11 –c –U sa –P *******
DAC (-A): sqlcmd –A –d master –S PAXT3DEVSQL11 –c –U sa –P *******
Emergency: ALTER DATABASE test_db SET EMERGENCY
Ans: ALTER DATABASE test_db SET EMERGENCY
After you execute this statement SQL Server will shutdown the database and restart it without recovering it. This will allow you to view/query database objects, but the database will be in read-only mode. Any attempt to modify data will result in an error similar to the following:
Msg 3908, Level 16, State 1, Line 1 Could not run BEGIN TRANSACTION in database ‘test’ …..etc
ALTER DATABASE test SET SINGLE_USER
DBCC CHECKDB (‘test’, REPAIR_ALLOW_DATA_LOSS) GO
If the DBCC CHECKDB statement above succeeds the database is brought back online (but you’ll have to place it in multi-user mode before your users can connect to it). Before you turn the database over to your users you should run other statements to ensure its transactional consistency. If DBCC CHECKDB fails then there is no way to repair the database – you must restore it from a backup.
Ans: No not possible for SQL Server 2005. To rollback an SP you have to uninstall the entire product and reinstall it.
For SQL Server training Bangalore 2008 you can uninstall an SP from Add/Remove programs.
Some people are saying that we can do it by backup and replace the resource DB. But I am not sure about that.
Ans: Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the other’s piece. Each process would wait indefinitely for the other to release the lock unless one of the user processes is terminated. SQL Server detects deadlocks and terminates one user’s process.
A livelock is one, where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.
Ans: Connect using DAC via CMD or SSMS
Find the errors from SQL log using
SQLCMD –A –SmyServer –q”Exec xp_readerrorlog” –o”C:logout.txt”
A long-running query blocking all processes and not allowing new connections
Write a query and put the script file on hard disk Ex: D:ScriptsBlockingQuery.sql
select p.spid, t.text
from sys processes p
CROSS APPLY sys.dm_exec_sql_text (sql_handle) t
where p.blocked = 0
and p.spid in
( select p1.blocked
from sys processes p1
where p1.blocked > 0
and p1.waittime > 50 )
From the command prompt run the script on the SQL server and get the result to a text file
SQLCMD -A – SMyServer -i” C:SQLScriptsGetBlockers.sql” -o” C:SQLScriptsblockers.txt”
Recently added some data files to temp DB and after that SQL Server is not responding
This can occur when you specify new files in a directory to which the SQL Server service account does not have access.
Start the SQL Server in minimal configuration mode using the startup parameter “–f”. When we specify –f the SQL server creates new tempdb files at default file locations and ignores the current tempdb data files configuration. Take care when using –f as it keeps the server in single-user mode.
Once the server is started change the tempdb configuration settings and restart the server in full mode by removing the flag -f
A database stays in a SUSPECT or RECOVERY_PENDING State
Try to resolve this using CheckDB and any other DBCC commands if you can.
Last and final option is put the DB in emergency mode and run CHECKDB with repair_allow_data_loss
(Note: Try to avoid this unless you don’t have an option as you may lose large amounts of data)
Ans: I am not going to say one is better than others, but it depends on the requirements. We have a number of products in the market. But if I have the chance to choose one of them I will choose SQL SERVER because…..
So that we can say SQL SERVER is more than enough for any type of application.
Ans: Hotfixes are software patches that were applied to live i.e. still running systems. A hotfix is a single, cumulative package that includes one or more files that are used to address a problem in a software product (i.e. a software bug).
In a Microsoft SQL SERVER context, hotfixes are small patches designed to address specific issues, most commonly to freshly-discovered security holes.
Ex: If a select query returning duplicate rows with aggregations the result may be wrong….
Ans: In the SHRINKFILE command, SQL Server isn’t especially careful about where it puts the pages being moved from the end of the file to open pages towards the beginning of the file.
Fragmentation level is decreased
Ans: AES (256 bit)
The longer the key, the better the encryption, so choose longer keys for more encryption. However, there is a larger performance penalty for longer keys. DES is a relatively old and weaker algorithm than AES.
AES: Advanced Encryption Standard
DES: Data Encryption Standard
Ans: Memory and disk storage both refer to internal storage space in a computer. The term “memory” usually means RAM (Random Access Memory). The terms “disk space” and “storage” usually refer to hard drive storage.
Ans: Port 445. Named pipes communicate across TCP port 445.
Ans: SQL Server Error Log: The Error Log, the most important log file, is used to troubleshoot system problems. SQL Server retains backups of the previous six logs, naming each archived log file sequentially. The current error log file is named ERRORLOG. To view the error log, which is located in the %Program-Files%Microsoft SQL ServerMSSQL.1MSSQLLOGERRORLOG directory, open SSMS, expand a server node, expand Management, and click SQL Server Logs
SQL Server Agent Log: SQL Server’s job scheduling subsystem, SQL Server Agent, maintains a set of log files with warning and error messages about the jobs it has run, written to the %ProgramFiles%Microsoft SQL ServerMSSQL.1MSSQLLOG directory. SQL Server will maintain up to nine SQL Server Agent error log files. The current log file is named SQLAGENT.OUT, whereas archived files are numbered sequentially. You can view SQL Server Agent logs by using SQL Server Management Studio (SSMS). Expand a server node, expand Management, click SQL Server Logs, and select the checkbox for SQL Server Agent.
Windows Event Log: An important source of information for troubleshooting SQL Server errors, the Windows Event log contains three useful logs. The application log records events in SQL Server and SQL Server Agent and can be used by SQL Server Integration Services (SSIS) packages. The security log records authentication information, and the system log records service startup and shutdown information. To view the Windows Event log, go to Administrative Tools, Event Viewer.
SQL Server Setup Log: You might already be familiar with the SQL Server Setup log, which is located at %ProgramFiles%Microsoft SQL Server90Setup BootstrapLOGSummary.txt. If the summary.txt log file shows a component failure, you can investigate the root cause by looking at the component’s log, which you’ll find in the %Program-Files%Microsoft SQL Server90Setup BootstrapLOGFiles directory.
SQL Server Profiler Log: SQL Server Profiler, the primary application-tracing tool in SQL Server, captures the system’s current database activity and writes it to a file for later analysis. You can find the Profiler logs in the log .trc file in the %ProgramFiles%Microsoft SQL ServerMSSQL.1MSSQLLOG directory.
Ans: Xp_readerrorlog or sp_readerrorlog has 7 parameters.
Log_FileNo: -1: All logs
0: Current log file
1: No1 archived log file etc
Log_Type: 1: SQL Server
2: SQL Agent
KeyWord-1: Search for the keyword
KeyWord-2: Search for a combination of Keyword 1 and Keyword 2
Date1 and Date2: Retrieves data between these two dates
‘Asc’/’Desc’: Order the data
EXEC Xp_readerrorlog 0 – Current SQL Server log
EXEC Xp_readerrorlog 0, 1 – Current SQL Server log
EXEC Xp_readerrorlog 0, 2 – Current SQL Agent log
EXEC Xp_readerrorlog -1 – Entire log file
EXEC Xp_readerrorlog 0, 1, ’dbcc’ – Current SQL server log with dbcc in the string
EXEC Xp_readerrorlog 1, 1, ’dbcc’, ’error’ – Archived 1 SQL server log with dbcc and error in the string
EXEC xp_readerrorlog -1, 1, ‘dbcc’, ‘error’, ‘2012-02-21’, ‘2012-02-22′,’desc’
Search entire sql server log file for string ‘dbcc’ and ‘Error’ within the given dates and retrieves in descending order.
Note: Also, to increase the number of log files, add a new registry key “NumErrorLogs” (REG_DWORD) under below location. HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSSQL.XMSSQLServer By default, this key is absent. Modify the value to the number of logs that you want to maintain.
Ans: I would store these as XML based files and not in the MSDB database. With the configuration files, you can point the packages from prod to dev (and vice versa) in just a few seconds. The packages and config files are just stored in a directory of your choice. Resources permitting, create a standalone SSIS server away from the primary SQL Server
Ans: You may want to add insert timestamps and update timestamps for each record. Every time a new record is inserted, stamp it with the DayTime and also stamp it with the date-time when updated. Also possibly use partitioning to reduce index rebuilds.
Ans: Check out the charts in this document. It shows how the disks are setup. It will depend on what the customer wants to spend and the level of reliability needed. Raid 5 is common, but see the topic ‘RAID 10 versus RAID 5 in Relational Databases’, in the document below. It’s a good discussion. Raid 10 (pronounced Raid one-zero) is supposed to have the best in terms of performance and reliability, but the cost is higher.
Ans: By far, the most effective configuration is to set tempdb on its own separate fast drive away from the user databases. I would set the number of files based on # of cpu’s divided by 2. So, if you have 8 cpu’s, then set 4 tempdb files. Set the tempdb large enough with 10% data growth. I would start at a general size of 10 GB for each size. I also would not create more than 4 files for each mdf/ldf even if there were more than 8 cpu’s. you can always add more later.
Ans: If it is active/passive, there is a good chance the transaction died, but active/passive is considered by some the better as it is not as difficult to administer. I believe that is what we have on active. Still, active/active may be best depending on what the requirements are for the system.
Ans: Open Cluster Administrator, check the SQL Server group where you can see the current owner. So the current owner is the active node and other nodes are passive.
Ans: Deadlock Information: 1204, 1205, 1222
Network Database files: 1807
Log Record for Connections: 4013
Skip Startup Stored Procedures: 4022
Disable Locking Hints: 8755
Forces uniform extent allocations instead of mixed page allocations 1118 – (SQL 2005 and 2008) To reduce TempDB contention.
Ans: All sys objects are physically stored in the resource database and logically available on every database.
Resource database can faster the service packs or upgrades
Ans: Yes, in earlier versions upgrades requires dropping and recreating system objects now an upgrade requires a copy of the resource file.
We are also capable of the rollback the process because it just needs to overwrite the existing with the older version resource copy.
Ans: No only resource db cannot be moved, Resource db location is always depends on Master database location, if u want to move resource db you should also move master db.
Ans: No way. The only way if you want to get a backup is use windows backup for option resource MDF and pdf files.
Ans: I do alter column to BigInt
Ans: Yes I am sure.
Let’s take few examples and see how many years will it take for BIGINT to reach its upper limit in a table:
(A) Considering only positive numbers, Max limit of BIGINT = 9,223,372,036,854,775,807
(B) Number of Seconds in a year = 31,536,000
Assume there are 50,000 records inserted per second into the table. Then the number of years it would take to reach the BIGINT max limit is:
9,223,372,036,854,775,807 / 31,536,000 / 50,000 = 5,849,424 years
If we inserted 1 lakh records per second into the table then it would take 2,924,712 yrs
If we inserted 1 million (1000000) records per second into the table then it would take 292,471 yrs
If we inserted 10 million (10000000) records per second into the table then it would take 29,247 yrs
If we inserted 100 million records per second into the table then it would take 2,925 yrs
If we inserted 1000 million records per second into the table then it would take 292 yrs
By this we would have understood that it would take extremely lots of years to reach the max limit of BIGINT.
Ans: System databases are the default databases that are installed when the SQL Server is installed. Basically, there are 4 system databases: Master, MSDB, TempDB, and Model. It is highly recommended that these databases are not modified or altered for the smooth functioning of the SQL System.
A user database is a database that we create to store data and start working with the data.
Ans: Primarily, the recovery model is chosen to keep in view the amount of data loss one can afford to. If one expects to have minimal or no data loss, choosing the Full recovery model is a good choice. Depending on the recovery model of a database, the behavior of database log file changes. I would recommend you read more material on log backups and log file behavior and so on to understand in depth.
Ans: Replication is a feature in SQL Server that helps us publish database objects and data and copy (replicate) it to one or more destinations. It is often considered as one of the High-Availability options. One of the advantages of Replication is that it can be configured on databases which are in simple recovery model.
Ans: There are basically 3 types of replication: Snapshot, Transactional and Merge Replication. The type of Replication you choose depends on the requirements and/or the goals one is trying to achieve. For example, Snapshot Replication is useful only when the data inside the tables does not change frequently and the amount of data is not too large, such as a monthly summary table or a product list table, etc. Transactional Replication would useful when maintaining a copy of a transactional table such as sales.
Ans: You need to add only FAILOVER PARTNER information in your front end code. “Data Source=ServerA;Failover Partner=ServerB;Initial Catalog=AdventureWorks;Integrated Security=True;”.
Ans: Secondary server. This question is basically asked to find out whether you have a hands on work on log shipping or not.
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .