convert

Mr. Bart Pietercil bart.pietercil at gmail.com
Fri Mar 28 11:05:11 CDT 2008


Hi Ivan,

this is what Danny ment and would like to see functioning:

select levelname,ranking ,(cast(levelname as integer)) as intLevel  
from tbl_score_levels where objptr_rs = 1 order by intLevel

This query works if I leave out the order by part. Strangely enough  
the '(cast(levelname as integer)) as intLevel' is not rejected but it  
is not included in the resultcursor neither.

So what we would like to do is have a varchar field that we would like  
to sort like a number (because for this query levelname only has  
numbers in it) and this 'should' work as we feel it.
This is why casting is for , no ?

tia

Bart




On 28-mrt-08, at 15:45, Sims, John (CDC/CCHP/NCBDDD) (CTR) wrote:
> Hi Ivan,
>
> CONVERT is a function provided in SQL Server (Possibly others).  It
> works inline and does not change the actual stored data.  This is the
> info from SQL Server Books Online:
>
> CAST and CONVERT
> Explicitly converts an expression of one data type to another. CAST  
> and
> CONVERT provide similar functionality.
>
> Syntax
> Using CAST:
>
> CAST ( expression AS data_type )
>
> Using CONVERT:
>
> CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
>
> Arguments
> expression
>
> Is any valid Microsoft(r) SQL Server(tm) expression. For more
> information, see Expressions.
>
> data_type
>
> Is the target system-supplied data type, including bigint and
> sql_variant. User-defined data types cannot be used. For more
> information about available data types, see Data Types.
>
> length
>
> Is an optional parameter of nchar, nvarchar, char, varchar, binary, or
> varbinary data types.
>
> style
>
> Is the style of date format used to convert datetime or smalldatetime
> data to character data (nchar, nvarchar, char, varchar, nchar, or
> nvarchar data types), or the string format when converting float,  
> real,
> money, or smallmoney data to character data (nchar, nvarchar, char,
> varchar, nchar, or nvarchar data types).
>
>
> Example:
>
> SELECT SUBSTRING(title, 1, 30) AS Title, ytd_sales
> FROM titles
> WHERE CONVERT(char(20), ytd_sales) LIKE '3%'
>
> HTH,
>
> - John Sims
>
>
>
>> -----Original Message-----
>> From: valentina-bounces at lists.macserve.net
>> [mailto:valentina-bounces at lists.macserve.net] On Behalf Of Ivan  
>> Smahin
>> Sent: Friday, March 28, 2008 9:49 AM
>> To: Valentina Developers
>> Subject: Re[4]: convert
>>
>> Hello Danny,
>>
>> Friday, March 28, 2008, 3:39:52 PM, you wrote:
>>
>>> So there is no other way but changing te table structure?
>>
>> But you are trying to apply some convert. Is it not the same?
>> Of course you can create another table and load data there.
>>
>>
>> --
>> Best regards,
>> Ivan Smahin
>> Senior Software Engineer
>> Paradigma Software, Inc
>> Valentina - The Ultra-Fast Database
>> http://www.valentina-db.com
>>
>> _______________________________________________
>> Valentina mailing list
>> Valentina at lists.macserve.net
>> http://lists.macserve.net/mailman/listinfo/valentina
>>
>>
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina



More information about the Valentina mailing list