Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is faster in a SQL Select Char or Integer?
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01520691
Message ID:
01520716
Vues:
44
>>>>>I would expect the second to win, but it may be not as clear, so at least some testing (even with light load for now) is required from your part.
>>>>>
>>>>>BTW, you don't need RTRIM() for the LEN function as it automatically removes trailing spaces.
>>>>
>>>>Thank you for your suggestions. But the LTRIM() is still necessary with LEN()? otherwise, LEN() will return the size of the column; correct?
>>>>
>>>>As to testing, sorry no time for that. I have to trust yours and Gregory's judgement and go with that. If things don't work, at least I have some smart people I can blame <g>
>>>
>>>Dmitry,
>>>
>>>In SQL Server it's not always 100% simple answer. You can not rely on the forums' answers if you don't do at least a simple test yourself.
>>>
>>>Take a look (even if you don't have time right now) for this yesterday's post by Ted Krugger
>>>
>>>A trigger can do that!
>>>
>>>to see why it's important to do tests.
>>>
>>>BTW, this reminds me - may be I need to write a blog post also to share my recent experience (even if it will be a bit late to participate).
>>>Try
>>>
>>>declare @t table (St char(20))
>>>
>>>insert into @t
>>>values ('  Dmitry'),('Dmitry   '),('Dmitry'), ('Dima')
>>>
>>>select LEN(St) as [Len], St, Datalength(St) as [DtLen],  LEN(LTRIM(St)) as [LtrimLen] from @t
>>>
>>>
>>> to see how LEN function works.
>>
>>Thank you. I copied your code (exactly) into the query window of SQL server but get an error (something near ","). I am sure it is only a typo or I copied incorrectly.
>
>There is an extra comma here.
>
>And yes, I wrote from the top of my head, haven't tested myself (don't have time :))
>
>I corrected the typo in the above.

Thank you. I get your point.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform