Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How to delete multiple rows with one delete statement in ms sql server?

1025


What is the difference between indexing and hashing?

1169


What is the difference between sdf and mdf?

1300


How do I start sql server agent automatically?

973


How to find index size for each index on table?

1003


What is the purpose of update statistics and scope_identity() function?

1100


what are the different ways of moving data/databases between servers and databases in sql server? : Sql server database administration

985


what's the information that can be stored inside a bit column? : Sql server database administration

1035


How many triggers you can have on a table?

995


Will count(column) include columns with null values in its count?

1094


what is database replicaion? What are the different types of replication you can set up in sql server? : Sql server database administration

989


what is the difference between Delete and Truncate command in SQL

1147


What is an indexed view?

960


Explain the difference between delete,drop and truncate in SQL Server?

1103


Does sql server use t sql?

1027