Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 convert

Author  Topic 

eddie
Starting Member

45 Posts

Posted - 2002-06-21 : 10:58:15
I am doing some optimization and am looking for anything that will help.

I have some code as follows

Declare @mxid numeric(18,0)
select @mxid = max(convert(numeric(18,0),id_c)) + 1 from ra.trmstr

id_c is a character field, I know, it shouldn't be but it is. If I don't do the convert, since it is a character, it thinks 9089 is larger than 12098. When I try cast, it is about the same performance wise. Is this optimized fully or can it be tweaked? I have also tried putting a clustered index on the column which helps a little.

Thanks,
Eddie



setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-06-21 : 15:09:45
quote:

I am doing some optimization and am looking for anything that will help.

I have some code as follows

Declare @mxid numeric(18,0)
select @mxid = max(convert(numeric(18,0),id_c)) + 1 from ra.trmstr

id_c is a character field, I know, it shouldn't be but it is. If I don't do the convert, since it is a character, it thinks 9089 is larger than 12098. When I try cast, it is about the same performance wise. Is this optimized fully or can it be tweaked? I have also tried putting a clustered index on the column which helps a little.

Thanks,
Eddie



I see this post has been picked over with no bites so I'll take a stab.

If the intent of the column is to represent numeric data, why store it with a character type? The best optimization I see here is converting the data to a numeric type in the table.

Jonathan Boott, MCDBA
Go to Top of Page
   

- Advertisement -