| Author |
Topic |
|
Rayman
Starting Member
39 Posts |
Posted - 2010-09-23 : 12:25:07
|
| I am trying to produce a script to look at a table. Determine the database size and convert to integer from database_size. I am trying use convert with str function. Not sure if this is correct approach.Table: Database_sizeSQL2000 54.5SQL2005 2000.78SQL2000 12.4SQL2005 234.32Trying to round up to produceSQL2000 55SQL2005 2001SQL2000 12SQL2005 234Any help would be appreciated. :-)Terry Lynn King |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-23 : 12:30:48
|
| Use ROUND(sizefield,0)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Rayman
Starting Member
39 Posts |
Posted - 2010-09-23 : 12:45:32
|
| this did work for me when using the followingcommandselect database_size from terri where (database_size = Round(database_size, 1))I wsa not clear sorry. I would like to look at all the values in the table and produce the results when not knowing the vaule. I would like to run this script against any database and retrieve the information. That is where I am tripped up. Thank you, TLKing------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/[/quote]Terry Lynn King |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-23 : 12:49:18
|
| not sure how it worked for you but ROUND(54.5,1) gives the same value itself------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Rayman
Starting Member
39 Posts |
Posted - 2010-09-23 : 13:04:10
|
Yes, that was my example. Would like to exam the data regardless ofdb and produce the desire output. Using the Function Round currently I have to place the number in the code. I am not sure if I am asking the question right.But I would like to look at the table Terry_Lynn_sizeand look at the numbers and them round up the numbers. I was trying to round and convert to integer from the terri_lynn_size. Do that sound correct? Sorry I am new to SQL. quote: Originally posted by visakh16 not sure how it worked for you but ROUND(54.5,1) gives the same value itself------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Terry Lynn King |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-23 : 13:06:35
|
| ok thats fine. but rounding to integer you require ROUND(field,0)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Rayman
Starting Member
39 Posts |
Posted - 2010-09-23 : 13:41:29
|
| Sorry, I lost the concepts in the thread. My code is giving me incorrect syntax errors. I am not sure where I went down the wrong path?Terry Lynn King |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-23 : 13:44:38
|
| post the code then------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Rayman
Starting Member
39 Posts |
Posted - 2010-09-23 : 13:49:56
|
| SELECT datebase_sizeFROM tery_lynnWHERE (datebase_size = ROUND(345.494, 0))ORDER BY datebase_sizeThis is not working. I do not get a display. Not sure if I am using the code correctly for my task?Terry Lynn King |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-23 : 13:54:05
|
| what does datebase_size field contain? whats the datatype of that field?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Rayman
Starting Member
39 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-23 : 14:00:25
|
| you didnt answer me yet------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Rayman
Starting Member
39 Posts |
Posted - 2010-09-23 : 14:09:58
|
| The column name is datebase_sizeThe script does not display errors. It does not return a value. I changed the vaules to see if I had the numeric_expression wrong or the length incorrect.Syntax: Round (numerical_expression,Length[,Function])What I am trying to do is add this to a select statement to view the size of the database and provide the size rounded up. I am new to this and appreciate all your helpTerry Lynn King |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Rayman
Starting Member
39 Posts |
Posted - 2010-09-23 : 14:13:48
|
| 12.4054.50234.322254.78Terry Lynn King |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Rayman
Starting Member
39 Posts |
Posted - 2010-09-23 : 14:32:34
|
| SELECT datebase_size select round(54.50,1), round(2254.78,1), round(12.40,1), round(234.32,1)FROM JohnMsg 207, Level 16, State 1, Line 14Invalid column name 'datebase_size'.Terry Lynn King |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Next Page
|