| Author |
Topic  |
|
|
danasegarane76
Posting Yak Master
India
232 Posts |
Posted - 08/23/2007 : 03:12:42
|
Hi gurus, I am running this qry in QueryAnyalzer.But it return the values as 0. I dont know wy?
declare @nst as numeric
set @nst=12333.00
select charindex('.',@nst)
Can some body help |
|
|
sutysw
Starting Member
3 Posts |
Posted - 08/23/2007 : 03:28:50
|
declare @nst as numeric(10, 2) set @nst=12333.00 select charindex('.',@nst) |
Edited by - sutysw on 08/23/2007 03:29:25 |
 |
|
|
danasegarane76
Posting Yak Master
India
232 Posts |
Posted - 08/23/2007 : 04:36:06
|
Thanks Sutysw, How can I use this with the select qry like select charindex('.',field1) from tblname
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 08/23/2007 : 04:38:52
|
It depends what you are trying to use it for. I have no idea. You haven't told how yuo are going to use it.
E 12°55'05.25" N 56°04'39.16" |
 |
|
|
danasegarane76
Posting Yak Master
India
232 Posts |
Posted - 08/23/2007 : 04:56:32
|
| I want to retrive the column value with two decimal places.The column is of decimal dattype |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 08/23/2007 : 05:02:02
|
quote: Originally posted by danasegarane76
I want to retrive the column value with two decimal places.
What does this mean?
1) You want to get all records which has exactly 2 decimals in a DECIMAL(x, 2) column? 2) You want to get all records which is not ".00" at the end? 3) You want to round or truncate all records to 2 decimals?
If you considered explaining yourself more clearly, you might get the answer you want faster!
E 12°55'05.25" N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 08/23/2007 : 05:03:27
|
danasegarane76, please post
1) Your table structure 2) Some data from the table 3) Your expected output based on the data above
E 12°55'05.25" N 56°04'39.16" |
 |
|
|
danasegarane76
Posting Yak Master
India
232 Posts |
Posted - 08/23/2007 : 05:59:36
|
Dear Peter, Thanks for ur reply.Here is the table structure and output requirment
create table test1 ( id int identity(1,1), [name] varchar(10), salary decimal(10,2) ) insert into test1([name],salary) values('dana1',12365.0000) insert into test1([name],salary) values('dana2',12365.12) --Now I want to the out put as -- [Name] salary -- dana1 12365.0000 -- dana2 12365.12
Thanks in Advance Dana
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 08/23/2007 : 06:49:49
|
Since the table only holds TWO decimals, how can you expect FOUR decimals in the result?
E 12°55'05.25" N 56°04'39.16" |
 |
|
|
danasegarane76
Posting Yak Master
India
232 Posts |
Posted - 08/23/2007 : 06:54:14
|
Oh Sorry, I have changed the decimals as 8(Soory for the mistake).Now I can I retrive the values /
Dana |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 08/23/2007 : 06:56:16
|
Did you use the ROUND(Salary, 2) function?
E 12°55'05.25" N 56°04'39.16" |
 |
|
|
danasegarane76
Posting Yak Master
India
232 Posts |
Posted - 08/23/2007 : 08:29:29
|
Dear Peter, I tried this one
select [name],round(salary,2) from test1
and it gave me the result as
dana1 12365.00000 dana2 12365.12000
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 08/23/2007 : 10:38:54
|
Yes, and what do you expect?
SELECT [Name], CAST(Salary AS DECIMAL(8,2)) FROM Test1
E 12°55'05.25" N 56°04'39.16" |
 |
|
|
danasegarane76
Posting Yak Master
India
232 Posts |
Posted - 08/23/2007 : 23:44:13
|
Thanks Peter, Thats what i wanted . Thanks a Lot
Danasekarane |
 |
|
| |
Topic  |
|