Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to detect query type

Author  Topic 

serpent
Starting Member

2 Posts

Posted - 2009-02-12 : 02:01:34
There are only two types of queries that we can run on Database. One that can change the state of the Database (like insert,update,delete,create). Second that can't change the state like select queries.

My question is that, is there any way to detect the type of query (whether it will change the state or not) before executing the query on database?

Parsing the query string with regular expersion is one way. But is there any other better way to do this thing? If parsing is the only option tell me what is the most optimize way to detect query type.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-12 : 02:07:33
There are other types of queries that you can run on a database, such as CREATE and ALTER.

Why do you want to detect this? Are you concerned about performance?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-12 : 02:11:17
You have DDL statement (ALTER, DROP, CREATE and so on) and you have DML statements (SELECT, DELETE, UPDATE and INSERT).



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -