I am sorry for the confusion. I used the following script and I am getting this error with only one database information is displaying instead 6 database including systems db's.
,ISNULL((select B.[UsedSpace(MB)]
from [TESTDB].[dbo].DB_USAGE B
where B.[SQLName] = a.[SQLName]
and B.[DBName] = a.[DBName]
and DATEPART(yyyy, B.[ExecuteTime]) = DATEPART(yyyy, DATEADD(mm, -1, a.[ExecuteTime]))
and DATEPART(MM, B.[ExecuteTime]) = DATEPART(MM, DATEADD(mm, -1, a.[ExecuteTime]))),0) AS Data_Usage_Growth
***subquery returned more than 1 value. This is not permitted when the subquery follows=,!=,<=,>= or when subquery is used as an expression.***
I asked very early on for your process, and then Dave has asked again in a more clear way for the same info.
We really need to see the script to create the table you are using to hold this data. We need to see the script you are using to put data into that table. And we need sample data to give you a better solution that any that have been offered thus far.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Syed Jahanzaib Bin hassan (4/22/2011)
Check this script if you have any problem or modification required then tell me
Regards,
Syed Jahanzaib Bin Hassan
MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA
My Blog
http://www.aureus-salah.com[/quote%5D
Here's a modification:
DECLARE @StartTime DATETIME, @EndTime DATETIME
SET @StartTime = DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)
SET @EndTime = DATEADD(dd,1+DATEDIFF(dd,0,GETDATE()),0)
SELECT
DBNAME,
CURRENT_LOG_SIZE = SUM(CASE WHEN TYPE_DESC = 'LOG' AND SIZE_DATE >= @StartTime AND SIZE_DATE < @EndTime THEN FILE_SIZE ELSE 0 END) / 128,
TOTAL_DATABASE_SIZE = (SUM(CASE WHEN TYPE_DESC = 'LOG' AND SIZE_DATE >= @StartTime AND SIZE_DATE < @EndTime THEN FILE_SIZE ELSE 0 END) / 128)
+ (SUM(CASE WHEN TYPE_DESC = 'ROWS' AND SIZE_DATE >= @StartTime AND SIZE_DATE < @EndTime THEN FILE_SIZE ELSE 0 END) / 128),
CURRENT_DATA_SIZE = SUM(CASE WHEN TYPE_DESC = 'ROWS' AND SIZE_DATE >= @StartTime AND SIZE_DATE < @EndTime THEN FILE_SIZE ELSE 0 END) / 128,
LAST_DAY_DATA_SIZE = SUM(CASE WHEN TYPE_DESC = 'ROWS' AND SIZE_DATE >= DATEADD(dd,-1,@StartTime) AND SIZE_DATE < DATEADD(dd,-1,@EndTime) THEN FILE_SIZE ELSE 0 END) / 128,
PER_DAY_INCREMENT = (SUM(CASE WHEN TYPE_DESC = 'ROWS' AND SIZE_DATE >= @StartTime AND SIZE_DATE < @EndTime THEN FILE_SIZE ELSE 0 END) / 128)
- (SUM(CASE WHEN TYPE_DESC = 'ROWS' AND SIZE_DATE >= DATEADD(dd,-1,@StartTime) AND SIZE_DATE < DATEADD(dd,-1,@EndTime) THEN FILE_SIZE ELSE 0 END) / 128),
PER_MONTH_INCREMENT = (SUM(CASE WHEN TYPE_DESC = 'ROWS' AND SIZE_DATE >= DATEADD(dd,-30,@StartTime) AND SIZE_DATE < @EndTime THEN FILE_SIZE ELSE 0 END) / 128)
- (SUM(CASE WHEN TYPE_DESC = 'ROWS' AND SIZE_DATE >= DATEADD(dd,-60,@StartTime) AND SIZE_DATE < DATEADD(dd,-30,@EndTime) THEN FILE_SIZE ELSE 0 END) / 128)
FROM DBINFO
WHERE TYPE_DESC IN ('LOG','ROWS')
AND SIZE_DATE >= DATEADD(dd,-60,@StartTime)
GROUP BY DBNAME
The original version has an uncomfortable proportion of hobby code in it.
My DBA would have a bigger problem if I saw him using this:
FROM DBINFO TMP1
WHERE DBID IN(SELECT DISTINCT DBID FROM DBINFO)
He'd be returned to HR.
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
David Burrows (4/26/2011)
hydbadrose (4/26/2011)
Ok so for the following script how would you change in whole;As I already stated
DDL to create the table (including indexes) Sample data to test with (important especially for ExecuteTime, ie does it contain time and only exists once per month?) without this there is not much we can do
Stop panicking for 1 second. Get an english interpreter if you need to. READ WHAT WE SAY. Stop focussing on your darn problem and let us help you.
I gave up- I am not getting any friendly reply...
Viewing 15 posts - 16 through 30 (of 37 total)
You must be logged in to reply to this topic. Login to reply