InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
SQL Query to find the date when new column is added or modified in sql table? |
|
Answer» SQL QUERY to find the date when new column is added or modified in sql table? Below is the SQL query to GET the DETAILS of when new column is added or modified:- SELECT OBJECT_NAME(sc.[object_id]) as [table_name] ,sc.[NAME] as [column_name] ,so.modify_date ,so.create_date FROM [sys].[columns] sc JOIN [sys].[objects] so ON sc.[object_id] = so.[object_id] ORDER BY so.modify_date DESC, so.create_date ASC |
|
| 2. |
A simple example of Pivot table in SQL Server(Column into Row)? |
|
Answer» A simple example of Pivot table in SQL Server(Column into Row)? |
|
| 3. |
Write a SQL in built function which will return the count of active transactions? |
|
Answer» Write a SQL in built function which will RETURN the COUNT of active transactions? |
|
| 4. |
How to set query to apply paging in SQL Query to get records? |
|
Answer» How to set QUERY to apply paging in SQL Query to get records? |
|
| 5. |
We have define nchar(3) and char(3) what is difference? |
|
Answer» We have define NCHAR(3) and CHAR(3) what is difference? |
|
| 6. |
SQL Query to disable or unable foreign key constraints temporarily by using TSQL? |
|
Answer» SQL Query to disable or UNABLE foreign KEY constraints temporarily by using TSQL? |
|
| 7. |
Query to get last occurrence of any character from any string? |
|
Answer» QUERY to GET last occurrence of any character from any string? Below is the query which will helps you to find last occurrence of PARTICULAR characters SELECT CHARINDEX('o', reverse('Crackyourinterview.com')) AS LastPosition |
|
| 8. |
Code to handle and delete Node from XML with childnode values? |
|
Answer» CODE to handle and DELETE Node from XML with childnode VALUES? Below is the code to handle Node values from XML with childnode and values:- Download Code ![]() |
|
| 9. |
Get last 4 charcters of string in SQL Server query? |
|
Answer» Get last 4 CHARCTERS of string in SQL SERVER query? |
|
| 10. |
Different SQL query to get details of every column in table with details? |
|
Answer» Different SQL QUERY to get details of every column in table with details? |
|
| 11. |
Query to repeat rows N times as per the column Value in SQL Server? |
|
Answer» Query to repeat ROWS N TIMES as PER the COLUMN Value in SQL Server? |
|
| 12. |
What action plan you create when SQL Server is not responding? |
|
Answer» What ACTION plan you create when SQL Server is not responding? |
|
| 13. |
How to retrieve unsaved SQL query script or files? |
|
Answer» How to retrieve UNSAVED SQL query script or files? |
|
| 14. |
Can store procedure be recursive if yes then its level? |
|
Answer» Can store procedure be recursive if YES then its level? |
|
| 15. |
Write a query to get all even and odd number if we have some id column? |
|
Answer» Write a query to GET all even and odd number if we have some id COLUMN? |
|
| 16. |
How to use xp_cmdshell in SQL? |
|
Answer» How to USE xp_cmdshell in SQL? |
|
| 17. |
Can we execute DOS command from SQL. |
|
Answer» Can we EXECUTE DOS COMMAND from SQL. |
|
| 18. |
How to change schema name of the Table in SQL Like dbo to crackuser? |
|
Answer» How to change schema NAME of the Table in SQL Like dbo to crackuser? |
|
| 19. |
Create table in SQL to store error in try catch block? |
|
Answer» CREATE table in SQL to store ERROR in try catch block? Below is the structure and the COLUMN details which will record all the ERRORS in try catch blocks.
|
|
| 20. |
Use of try catch and in store procedure and display error too in details? |
|
Answer» Use of try catch and in store PROCEDURE and display error too in details? |
|
| 21. |
Can you differentiate between LEN() and DATALENGTH() in SQL? |
|
Answer» Can you differentiate between LEN() and DATALENGTH() in SQL? |
|
| 22. |
Differentiate between Wide and Nonwide tables in SQL Server? |
|
Answer» DIFFERENTIATE between Wide and Nonwide TABLES in SQL Server? Below are the some COMMON DIFFERENCE between Wide and Non-wide in SQL Server |
|
| 23. |
Write down a query to concatenate string in single column separate by comma? |
|
Answer» WRITE down a query to concatenate STRING in single COLUMN separate by comma? To write down this query i have create a #temptable and then write query to concate string in single column. Here i have use TWO ways to do that as per below screen
|
|
| 24. |
Write down a SQL Query to convert first letter in Upper case and Rest in lower case in Name? |
|
Answer» Write down a SQL QUERY to CONVERT FIRST LETTER in UPPER case and Rest in lower case in Name? |
|
| 25. |
Write down a SQL Query to find the missing number in Auto increment column? |
|
Answer» Write down a SQL QUERY to find the missing number in AUTO increment column? |
|
| 26. |
How to insert missing SQL Server IDENTITY column values? |
|
Answer» How to insert missing SQL Server IDENTITY column values? |
|
| 27. |
Write down a Dynamic SQL Query with syntax in SQL? |
|
Answer» Write down a Dynamic SQL Query with syntax in SQL? |
|
| 28. |
Get DateTime different parts from SQL Query with syntax? |
|
Answer» GET DateTime DIFFERENT parts from SQL Query with SYNTAX? Below is the query to get different parts from SQL Query with code:- |
|
| 29. |
Define different function to get the current users details? |
|
Answer» Define different FUNCTION to GET the current USERS DETAILS? |
|
| 30. |
Error handling in SQL by using Try Catch Block? |
|
Answer» ERROR handling in SQL by using Try CATCH Block? Below code will be used to test the SQL Try Catch blocks here we use one error divide by zero to test.
|
|
| 31. |
some good sql query |
|
Answer» ---How to get number of days in a month select CASE WHEN MONTH(getdate()) IN (1, 3, 5, 7, 8, 10, 12) THEN 31 WHEN MONTH(getdate()) IN (4, 6, 9, 11) THEN 30 ELSE CASE WHEN (YEAR(getdate()) % 4 = 0 AND YEAR(getdate()) % 100 != 0) OR (YEAR(getdate()) % 400 = 0) THEN 29 ELSE 28 END end ---How to get number of row in each table in database SELECT obj.NAME, ind.rowcnt FROM sysindexes AS ind INNER JOIN sysobjects AS obj ON ind.id = obj.id WHERE ind.indid < 2 AND OBJECTPROPERTY(obj.id, 'IsMSShipped') = 0 ORDER BY obj.NAME ---How to select all duplicate records from a table select Coloumn_name, count(Coloumn_name) from Table_Name group by field having count(*) > 1 ---How to get first DAY of current week (Sunday) select DATEADD(DD, 1 - DATEPART(DW, getdate()),getdate()) ---How to get first day of current week (Monday) select DATEADD(DD, 1 - DATEPART(DW, getdate()),getdate()+1) ---How to get number of MAXIMUM connection can be establish to SQL SELECT MAX_CONNECTIONS ----query to convert all the letters in a word to upper case SELECT UPPER('test') ----round up the values of a number SELECT CEILING (7.1) ---How to get first day of Month SELECT DATENAME(dw, DATEADD(dd, - DATEPART(dd, GETDATE()) + 1,GETDATE())) AS FirstDay ---How to know how many tables contains column_name as a column in a database SELECT COUNT(*) AS Counter FROM syscolumns WHERE (name = 'column_name') |
|
| 32. |
How to get the table count in last used query from cache by sending tablename? |
|
Answer» How to GET the table count in LAST used query from CACHE by SENDING tablename? |
|
| 33. |
Write a SQL query to print 1 to 100 in sql server? |
|
Answer» WRITE a SQL query to PRINT 1 to 100 in sql server? There are 2 methods to do that ONE is with while loop and ANOTHER one is with with statement (1)Method1 ;WITH CTE AS ( SELECT 1 [Sequence] UNION ALL SELECT [Sequence] + 1 FROM CTE WHERE [Sequence] <100 ) SELECT * FROM CTE (2)Method2 By Using Loop declare a INT set a=0; While(a<100) begin select a=a+1 print a end |
|
| 34. |
Sql Interview Latest Query questions asked on 30 dec 2020 |
|
Answer» Sql Interview Latest Query questions asked on 30 dec 2020 |
|
| 35. |
nth highest number from table |
|
Answer» Hi PUT NUMBER in the place of nth |
|
| 36. |
Remove last or first character from string in SQL Query? |
|
Answer» Remove LAST or first character from STRING in SQL Query? |
|
| 37. |
Can we blocks execution of batch, store procedure or transaction in SQL for certain time? |
|
Answer» Can we blocks execution of batch, store PROCEDURE or transaction in SQL for certain time? |
|