June 12, 2018 at 3:15 am
SELECT
[DB]
FROM [LogNewTables]
where Newtable > 0
and logDate > Dateadd(dd,-1,Getdate())
If @@rowcount > 0
Begin
<do the magic here>
end
I can’t for the life of me figure out how to return an error when the query returns multiple rows.
Single row is not an issue.
I want to display the DBNAME when multiple dbs have had new tables created which will notify the DBAs when this has occurred.
June 12, 2018 at 3:31 am
Set up a custom message in sys.messages, then set up an alert for that that emails the DBA team maybe..
June 12, 2018 at 4:10 am
Thanks, I have resolved. Had a coffee and something to eat and my brain clicked into gear.
June 12, 2018 at 8:13 am
A DDL trigger that fires on CREATE TABLE would do this for you as well. Take a look this as it may be simpler.
June 12, 2018 at 8:21 am
Super Cat - Tuesday, June 12, 2018 4:10 AMThanks, I have resolved. Had a coffee and something to eat and my brain clicked into gear.
So what did you end up doing?
--Jeff Moden
Change is inevitable... Change for the better is not.
June 15, 2018 at 1:47 am
I was really simple. Embarrassed I posted now. Dumped the name in a temp table and just created a cursor to loop through and pump the db names in the error.
I will eat next time before starting work.
June 15, 2018 at 7:53 am
Super Cat - Friday, June 15, 2018 1:47 AMI was really simple. Embarrassed I posted now. Dumped the name in a temp table and just created a cursor to loop through and pump the db names in the error.I will eat next time before starting work.
How about posting your code.
June 15, 2018 at 7:55 am
Super Cat - Friday, June 15, 2018 1:47 AMI was really simple. Embarrassed I posted now. Dumped the name in a temp table and just created a cursor to loop through and pump the db names in the error.I will eat next time before starting work.
Heh... we've all been there, for sure. Thanks for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply