Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

I'm reading a book about SQL. In that book there's the term Ad Hoc Query, which I don't understand.

What exactly is an ad hoc query?

1 Answer

0 votes
by (40.4k points)

Ad hoc is a Latin word which means "for this purpose". You can call it as "on the fly" query, or the "just so" query. 

It's one kind of SQL query, that you just loosely type out where you need it.

var newSqlQuery = "SELECT * FROM table WHERE id = " + myId;

The above query is an entirely different query that occurs each time the line of code is executed, depending on the value of myId. 

A predefined query such as a Stored Procedure is the antonym of an ad hoc query. Here, you have created the single query for the entire generalized purpose of selecting from that table (say), and pass the ID as a variable.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 3, 2020 in BI by Vaibhav Ameta (17.6k points)
0 votes
0 answers
asked Jun 24 in SQL by Harsh (1.5k points)
0 votes
1 answer
asked Dec 4, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
asked Oct 19, 2020 in SQL by dev_sk2311 (43.2k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories