How to show the execution time before the query result appears
Do you mean that your program displays a "Time to complete request" counter or a progress bar, for example, when you delete a large number of files in Windows Explorer?
This is not possible at all. Many requests cannot be estimated "in advance" without a significant amount of work, so the estimated completion time will not be available until the request is nearly complete.
A simple linear table lookup would be a simple case when it was possible, but adding other constraints or using indexes would cause headaches.
(Even the Windows example of deleting a large directory is fraught with problems - they need to scan the entire directory to count the files before they start deleting them so they can show you a progress bar, which is why I tend to clone large directories from the command line to to save time).
a source to share
How to show execution time before query result will be displayed
You can use "sys.dm_exec_requests", but it will only support a few of the operations listed below. Obviously it cannot support normal DML / select queries. sys.dm_exec_requests (Transact-SQL)
ALTER INDEX REORGANIZE
AUTO_SHRINK option with ALTER DATABASE
BACKUP DATABASE
CREATE INDEX
DBCC CHECKDB
DBCC CHECKFILEGROUP
DBCC CHECKTABLE
DBCC INDEXDEFRAG
DBCC SHRINKDATABASE
DBCC SHRINKFILE
KILL (Transact-SQL)
RESTORE DATABASE,
UPDATE STATISTICS.
a source to share