What is the diff between Static Queries and Dynamic queries
give me some examples
Answer Posted / manoj
Static Queries are permanent and cannot be changed during run-time, like: "SELECT * FROM Employees"
Dynamic Queries can be changed during run-time as they are created by using variables and these variables contain parts of SQL Query, like:
DECLARE @SQL VARCHAR(MAX)
DECLARE @WHENSQL VARCHAR(2000)
DECLARE @SEARCHSQL VARCHAR(500)
SELECT @WHENSQL = 'EmployeeID'
SELECT @SEARCHSQL = '100'
SELECT @SQL = 'SELECT * FROM Employees WHERE ' + @WHENSQL + ' = ' + @SEARCHSQL
EXEC (@SQL)
-- or
EXEC sp_executesql @SQL
For more interview Questions on SQL Server: http://sqlwithmanoj.wordpress.com/interview-questions/
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Give some Scenario for Non Clusterd index? Can we write system defined functions in side The Function? Wat is the Unique Datatype?
what is create database syntax? : Sql server database administration
Mention the different types of triggers?
Define right outer join in sql server joins?
What are the High-Availability solutions in SQL Server and differentiate them briefly?
What command is used to rename the database?
What is an example of a primary key?
What is sql injection and why is it a problem? : sql server security
Explain various data region available in ssrs with their use?
What is not null constraint?
Describe how to use the linked server?
Explain try...catch with sql server?
Tell me what is the significance of null value and why should we avoid permitting null values?
What security features are available for stored procedure?
Write a SQL query in order to merge two different columns into single column?