October 4, 2023 at 6:57 pm
CREATE TABLE #tempdblogin
(
lastcheck nvarchar(100)
)
EXEC sp_MSforeachdb 'USE ? insert into #tempdblogin SELECT DATABASEPROPERTYEX(DB_NAME(), "LastGoodCheckDbTime") '
SELECT * FROM #tempdblogin
DROP table #tempdblogin
getting the following error:
Implicit conversion from data type sql_variant to nvarchar is not allowed. Use the CONVERT function to run this query.
October 5, 2023 at 5:59 am
... convert( desired_date_type, DATABASEPROPERTYEX(DB_NAME(), "LastGoodCheckDbTime")) ...
I've modified your script a little bit to be more informative :
CREATE TABLE #lastcheckdb
(
DbName sysname,
Updateability sysname,
lastcheck datetime2(0) null
)
EXEC sp_MSforeachdb 'USE [?]; insert into #lastcheckdb SELECT db_name() as DbName, convert(sysname, DATABASEPROPERTYEX(DB_NAME(), ''Updateability'')) as Updateability, convert(datetime2(0),DATABASEPROPERTYEX(DB_NAME(), "LastGoodCheckDbTime"), 100) as lastcheck'
SELECT *
FROM #lastcheckdb
order by DbName;
DROP table #lastcheckdb ;
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
October 5, 2023 at 9:44 am
thanks so much, johan
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply