Showing posts with label varchar. Show all posts
Showing posts with label varchar. Show all posts

Monday, March 19, 2012

calculate and return % in Stored Procedure

This is my SP:

SELECT
CAST(id AS varchar(10)) + ' - ' + UserName AS 'User List',
Scanned,
Scripts AS 'Total Scripts',
Processed,
CAST((Processed/ Scripts)* 100.0 as int) AS 'DONE (%)'
FROM tblworkQueue


Processed and Scripts are both DataTypes of int
My DONE(%) column comes back with 0

Any idea where I am going wrong?

thats because you are CASTing it as INT, if the value is < 1 it will be 0. Try to cast it as decimal(10,2).|||

It is could be also if both your fields you use for dividing you useCAST((Processed/ Scripts)* 100.0 as int) processed and Scripts are integer values and I assume that processed is smaller so when you divide integers result is also integer so you get something below 1 and it is rounded to 0. try to use

CAST((100.00 *Processed/ Scripts) as int)

maybe it will work better?

Sunday, February 19, 2012

bytes used by datatypes

Where can i find how much bytes datatypes such as
int,datetime,money,bit,varchar consume ?
Thanks
Check BOL
Books Online...
Thanks,
Sree
[Please specify the version of Sql Server as we can save one thread and time
asking back if its 2000 or 2005]
"Hassan" wrote:

> Where can i find how much bytes datatypes such as
> int,datetime,money,bit,varchar consume ?
> Thanks
>
>
|||Check SQL Server Books Online
Jack Vamvas
___________________________________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
"Hassan" <Hassan@.hotmail.com> wrote in message
news:u9T5xLLQGHA.3192@.TK2MSFTNGP09.phx.gbl...
> Where can i find how much bytes datatypes such as
> int,datetime,money,bit,varchar consume ?
> Thanks
>
|||Look at Data Types in books online
Regards
Amish shah
Jack Vamvas wrote:
[vbcol=seagreen]
> Check SQL Server Books Online
> --
> Jack Vamvas
> ___________________________________
> Receive free SQL tips - www.ciquery.com/sqlserver.htm
> "Hassan" <Hassan@.hotmail.com> wrote in message
> news:u9T5xLLQGHA.3192@.TK2MSFTNGP09.phx.gbl...

bytes used by datatypes

Where can i find how much bytes datatypes such as
int,datetime,money,bit,varchar consume ?
ThanksCheck BOL
Books Online...
--
Thanks,
Sree
[Please specify the version of Sql Server as we can save one thread and
time
asking back if its 2000 or 2005]
"Hassan" wrote:

> Where can i find how much bytes datatypes such as
> int,datetime,money,bit,varchar consume ?
> Thanks
>
>|||Check SQL Server Books Online
--
Jack Vamvas
___________________________________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
"Hassan" <Hassan@.hotmail.com> wrote in message
news:u9T5xLLQGHA.3192@.TK2MSFTNGP09.phx.gbl...
> Where can i find how much bytes datatypes such as
> int,datetime,money,bit,varchar consume ?
> Thanks
>|||Look at Data Types in books online
Regards
Amish shah
Jack Vamvas wrote:
[vbcol=seagreen]
> Check SQL Server Books Online
> --
> Jack Vamvas
> ___________________________________
> Receive free SQL tips - www.ciquery.com/sqlserver.htm
> "Hassan" <Hassan@.hotmail.com> wrote in message
> news:u9T5xLLQGHA.3192@.TK2MSFTNGP09.phx.gbl...

bytes used by datatypes

Where can i find how much bytes datatypes such as
int,datetime,money,bit,varchar consume ?
ThanksCheck BOL
Books Online...
--
Thanks,
Sree
[Please specify the version of Sql Server as we can save one thread and time
asking back if its 2000 or 2005]
"Hassan" wrote:
> Where can i find how much bytes datatypes such as
> int,datetime,money,bit,varchar consume ?
> Thanks
>
>|||Check SQL Server Books Online
--
Jack Vamvas
___________________________________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
"Hassan" <Hassan@.hotmail.com> wrote in message
news:u9T5xLLQGHA.3192@.TK2MSFTNGP09.phx.gbl...
> Where can i find how much bytes datatypes such as
> int,datetime,money,bit,varchar consume ?
> Thanks
>|||Look at Data Types in books online
Regards
Amish shah
Jack Vamvas wrote:
> Check SQL Server Books Online
> --
> Jack Vamvas
> ___________________________________
> Receive free SQL tips - www.ciquery.com/sqlserver.htm
> "Hassan" <Hassan@.hotmail.com> wrote in message
> news:u9T5xLLQGHA.3192@.TK2MSFTNGP09.phx.gbl...
> > Where can i find how much bytes datatypes such as
> > int,datetime,money,bit,varchar consume ?
> >
> > Thanks
> >
> >