May 6, 2008 at 5:52 am
hi,
My query is working fine but I just want to know how to change the result like eg,5,4,6 GB i want to see in this format how can we use alias name for this .
select
BackupDate = convert(varchar(10),backup_start_date, 111),server_name,name
,SizeInGigs=floor( backup_size/1024000000)
from msdb..backupset
where
database_name = 'adventureworks'
and type = 'd'
order by
backup_start_date desc
May 6, 2008 at 6:26 am
It's not an alias you're looking for but some formatting. Try changing to this:
CAST(SizeInGigs=floor( backup_size/1024000000) AS VARCHAR) + ' GB'
An alias is a way of masking or changing a column or table name:
SELECT a.MyCol AS 'Dude'
FROM GreatBigTableName AS a
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
May 7, 2008 at 4:49 am
Grant Fritchey (5/6/2008)
It's not an alias you're looking for but some formatting. Try changing to this:
CAST(SizeInGigs=floor( backup_size/1024000000) AS VARCHAR) + ' GB'
An alias is a way of masking or changing a column or table name:
SELECT a.MyCol AS 'Dude'
FROM GreatBigTableName AS a
jagpalsingh4 (5/6/2008)
hi,My query is working fine but I just want to know how to change the result like eg,5,4,6 GB i want to see in this format how can we use alias name for this .
Jeff,
I think he wants single line of result with comma seperated. what you said is right but it will be seperate cells
May 7, 2008 at 4:53 am
shamshudheen (5/7/2008)
Jeff,
Who's Jeff?
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
May 7, 2008 at 5:01 am
Hi,
Really thaxx to everybody i have done what i need
select
BackupDate = convert(varchar(10),backup_start_date, 111),server_name,name,database_creation_date
, CAST((floor( backup_size/1024000000)) AS VARCHAR) + ' GB'as sizeinGB
from msdb..backupset
where
database_name = 'adventureworks'
and type = 'd'
order by
backup_start_date desc
Regards
Jagpal Singh
May 7, 2008 at 5:48 am
RyanRandall (5/7/2008)
shamshudheen (5/7/2008)
Jeff,Who's Jeff?
sorry not jeff
Ryan
your understanding is right....
May 7, 2008 at 5:57 am
No, no, no. Jeff's smarter and better looking. I'm.... uh, I'm.... Hey!
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
May 7, 2008 at 6:09 am
Grant Fritchey (5/7/2008)
No, no, no. Jeff's smarter and better looking. I'm.... uh, I'm.... Hey!
hey.. i confused.. i was saying to Grant not jeff and not ryan
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply