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
How you can get the list of largest tables in a database?
How to get the query of a table in sql server?
Does partitioning ssd reduce performance?
my name is sejal I have cleared the sbi clerk exam. I am BCA graduate My favorite subject RDBMS Relational database management system. so please send me rRDBMS related interview questions
What is msdb database? : SQL Server Architecture
What are two difference between sql azure and azure tables?
Does index speed up select statements?
How to create a large table with random data for index testing in ms sql server?
Can you explain what is indexed view? How to create it?
Can You Use Data Mining Models In Ssrs?
What are ddl triggers and types of ddl trigger?
What is the ‘fillfactor’?
How to connect to SQL Azure Database by using sqlcmd?
How to run sql server 2005 books online on your local system?
How do I view a stored procedure in sql server query?