Get a dll version number from database at compile time-Collection of common programming errors
is it possible at compile time to execute a SQL or any operation
to get this number
No you cannot call SQL at compile time. Compiling is purely for creating MSIL (dll or exe) to be executed later by the CLR. All work is performed by the JIT compiler of the CLR (which is at runtime). No work can be done at compile time.
However, you could add a pre build event (that would happen before the compilation), which gets data and writes it into a config file. The app can read the version number from here. 