Author |
Topic |
danasegarane76
Posting Yak Master
242 Posts |
Posted - 2007-08-23 : 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 numericset @nst=12333.00select charindex('.',@nst) Can some body help |
|
sutysw
Starting Member
3 Posts |
Posted - 2007-08-23 : 03:28:50
|
declare @nst as numeric(10, 2)set @nst=12333.00select charindex('.',@nst) |
|
|
danasegarane76
Posting Yak Master
242 Posts |
Posted - 2007-08-23 : 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
30421 Posts |
Posted - 2007-08-23 : 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
242 Posts |
Posted - 2007-08-23 : 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
30421 Posts |
Posted - 2007-08-23 : 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
30421 Posts |
Posted - 2007-08-23 : 05:03:27
|
danasegarane76, please post1) Your table structure2) Some data from the table3) Your expected output based on the data above E 12°55'05.25"N 56°04'39.16" |
|
|
danasegarane76
Posting Yak Master
242 Posts |
Posted - 2007-08-23 : 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.12Thanks in AdvanceDana |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-23 : 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
242 Posts |
Posted - 2007-08-23 : 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
30421 Posts |
Posted - 2007-08-23 : 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
242 Posts |
Posted - 2007-08-23 : 08:29:29
|
Dear Peter, I tried this one select [name],round(salary,2) from test1and it gave me the result asdana1 12365.00000dana2 12365.12000 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-23 : 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
242 Posts |
Posted - 2007-08-23 : 23:44:13
|
Thanks Peter, Thats what i wanted . Thanks a LotDanasekarane |
|
|
|