Subido por Danyller CALDERON CALDERON

SAInterviewQ&A

Anuncio
There are 3 baskets labeled ‘Apples’, ‘Oranges’ & ‘Mixture’. One of them contains only Apples,
one only Oranges and one has mix of apples and oranges both.
These baskets are not labeled correctly. In fact, the labels on these baskets always lie. (i.e. if the
label says Oranges, then you are sure the basket either has only Apples or Mixture).
You are allowed to pick one fruit from one basket (Not allowed to see other fruits), and you
have to put all the labels correctly on the basis of that information (by seeing only one fruit
from any one basket).
How will you do that?
Solution:
Pick a fruit from the basket labeled ‘Mixture’. We know from the question that this basket does not contain
‘Mixture’ for sure.
If this fruit is an apple, then label this Basket as ‘Apple’ (Because this basket does not contain Mixture, so if
one is apple, all are apples only). Now we’ve determined that the basket labeled as ‘Mixture’ only contains
Apples.
If we look at the basket labeled as ‘Oranges’, we know that since the label is incorrect, this basket either has
only apples in it or has Mixture. Since we already know which basket contains only apples, we know that the
basket labeled as ‘Oranges’ contains ‘Mixture’. So label it as ‘Mixture’. The 3rd basket will be labeled as
‘Oranges’.
2 What are Tables and Fields?
A table is an organized collection of data stored in the form of rows and columns. Columns can
be categorized as vertical and rows as horizontal. The columns in a table are called fields while
the rows can be referred to as records.
3 List the different types of relationships in SQL.




One-to-One - This can be defined as the relationship between two tables where each record in one table
is associated with the maximum of one record in the other table.
One-to-Many & Many-to-One - This is the most commonly used relationship where a record in a table is
associated with multiple records in the other table.
Many-to-Many - This is used in cases when multiple instances on both sides are needed for defining a
relationship.
Self Referencing Relationships - This is used when a table needs to define a relationship with itself.
4 What are the TRUNCATE, DELETE and DROP statements?
DELETE statement is used to delete rows from a table.
DELETE FROM Candidates
WHERE CandidateId > 1000;
TRUNCATE command is used to delete all the rows from the table and free the space containing the table.
TRUNCATE TABLE Candidates;
DROP command is used to remove an object from the database. If you drop a table, all the rows in the table
is deleted and the table structure is removed from the database.
DROP TABLE Candidates;
5. What is a Join? List its different types.
The SQL Join clause is used to combine records (rows) from two or more tables in a SQL database based on a
related column between the two.
There are four different types of JOINs in SQL:
(INNER) JOIN: Retrieves records that have matching values in both tables involved in the join. This
is the widely used join for queries.
LEFT (OUTER) JOIN: Retrieves all the records/rows from the left and the matched records/rows
from the right table.
RIGHT (OUTER) JOIN: Retrieves all the records/rows from the right and the matched records/rows
from the left table.
FULL (OUTER) JOIN: Retrieves all the records where there is a match in either the left or right table.
6 What are some common clauses used with SELECT query in SQL?
Some common SQL clauses used in conjuction with a SELECT query are as follows:
 WHERE clause in SQL is used to filter records that are necessary, based on specific conditions.
 ORDER BY clause in SQL is used to sort the records based on some field(s) in ascending (ASC) or
descending order (DESC).
 GROUP BY clause in SQL is used to group records with identical data and can be used in conjuction
with some aggregation functions to produce summarized results from the database.
 HAVING clause in SQL is used to filter records in combination with the GROUP BY clause. It is
different from WHERE, since WHERE clause cannot filter aggregated records.
7 What is a Stored Procedure?
A stored procedure is a subroutine available to applications that access a relational database
management system (RDBMS). Such procedures are stored in the database data dictionary. The sole
disadvantage of stored procedure is that it can be executed nowhere except in the database and
occupies more memory in the database server. It also provides a sense of security and functionality as
users who can't access the data directly can be granted access via stored procedures.
8 What Is SQL Profiler?
SQL Profiler is a tool which allows system administrator to monitor events in the SQL server. This is
mainly used to capture and save data about each event of a file or a table for analysis.
9 What is the difference between COMMIT and ROLLBACK?
Every statement between BEGIN and COMMIT becomes persistent to database when the COMMIT is
executed. Every statement between BEGIN and ROOLBACK are reverted to the state when the
ROLLBACK was executed.
10 One of your clients complains that he is not able to connect to the SQL Server and getting
the error message below. How could you troubleshoot it?
Login Failed for User ‘<domainname>\<username>’


Check that the database is accessible by another authorized user
Check that the user who is trying to connect has permission to perform that action to the
database
11 One of your clients complains that his application is receiving the below error message
frequently. How could you troubleshoot it?

Timeout expired. The timeout period elapsed prior to completion of the operation or the server
is not responding.
12 You are working as a SQL Server database administrator in a company. What does the UDL
file mean for you?
The UDL file is a connectivity check tool that can be used to test the connection to a local or remote
database engine using different types of connection providers that are installed on that machine.
It requires no installation. Just create an empty .txt file and rename it to .UDL. Then use it easily to
test the connection using the selected driver.
13
being evaluated by the SQL NOT IN condition contains any values that are null, then the outer query here will
return an empty set, even if there are many runner ids that match winner_ids in the races table.
Knowing this, a query that avoids this issue would be as follows:
SELECT * FROM runners WHERE id NOT IN (SELECT winner_id FROM races WHERE winner_id IS NOT null)
14
update TBL set Nmbr = case when Nmbr = 0 then Nmbr+2 else Nmbr+3 end;
15 #temp @temp ##temp
16 select first 5 characters from firstname in employee table
17 What is XML?
XML is called Extensible Markup Language which is designed to carry or transport and store
data. XML tags are not as predefined as HTML, but we can define our own user tags for
simplicity. It mainly concentrates on storing of data, not on displaying of data.
18 TCP IP config
Descargar