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.3k 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 in BI by Vaibhav Ameta (17.6k points)
0 votes
1 answer
asked Oct 19 in SQL by dev_sk2311 (14.9k points)
0 votes
1 answer
asked Apr 22 in SQL by Sudhir_1997 (43.7k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...