SQL
SQL
2.Types of Sub-Query
1.Single-row sub-query, where the sub-query returns only one row.
2.Multiple-row sub-query, where the sub-query returns multiple rows,. and
3.Multiple column sub-query, where the sub-query returns multiple columns
Can a stored procedure call itself or recursive stored procedure? How much level SP
nesting is possible?
Yes. Because Transact-SQL supports recursion, you can write stored procedures that call themselves.
Recursion can be defined as a method of problem solving wherein the solution is arrived at by
repetitively applying it to subsets of the problem. A common application of recursive logic is to perform
numeric computations that lend themselves to repetitive evaluation by the same processing steps.
Stored procedures are nested when one stored procedure calls another or executes managed code by
referencing a CLR routine, type, or aggregate. You can nest stored procedures and managed code
references up to 32 levels.
How would you find out the total number of rows in a table?
Use SELECT COUNT(*) … in query
The DROP command removes a table from the database. All the tables' rows, indexes and privileges
will also be removed.
Dropping Constraints:
Any constraint that you have defined can be dropped using the ALTER TABLE command with the DROP CONSTRAINT option.