implicit conversions, which should be avoided.

hi experts

i  am reading about tuning
what's the mean
Design the tables considering the implicit conversions, which should be avoided.

can you give me T-SQL code
enrique_aeoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
Please post where you are seeing this to provide context to your question.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
An example:
- Any varchar column that stores numeric digits (0..9) when used for a comparison, it will be implicitly converted to numeric.
SELECT *
FROM MyTable
WHERE MyVarcharID = 100

Open in new window

In the above example if MyVarcharID is for example a VARCHAR(4) field, the WHERE clause will make an implicit conversion, from VARCHAR(4) to INT so it can use the compare filter (= 100).
0
Maciej PileckiDatabase ArchitectCommented:
Implicit conversions happen anywhere where you are comparing columns (or expressions) of different datatypes.
Not all of them will be bad in the sense of causing performance issues but some will and it's a good idea to avoid them.

This is an example of a "nasty" implicit conversion:
SELECT *
FROM SomeTable
WHERE IntColumn = '100'

Open in new window

Note that the literal in this case is not an int but varchar (as indicated by single quotes). Since varchar has highier datatype precedence than int, all the values of IntColumn will have to be implicitly converted to varchar before comparing them to the literal.
Vitor (above) got it slightly wrong as the implicit conversion will always be int -> varchar, not the other way around.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.