I am writing a TSQL script which will run from osql (where the database name is passed in as a command-line parameter). Within that SQL I need to figure the database name to use it as data in the script.
In other words, I want to do something like this:-
declare @my_db varchar(80)
set @my_db = dbo.getCurrentDbName()
insert into myTable
select @my_db , current_timestamp
Any suggestions how to figure out the database name?