Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CONVERT question

Status
Not open for further replies.

djj55

Programmer
Feb 6, 2006
1,761
US
Hello, SQL 2008R2

What affect, if any, does having a style when converting from VARCHAR to VARCHAR
Code:
REPLACE(LEFT(CONVERT(varchar(50), PhoneNumber, 2), 11), '.', '')

I have a dynamic query. The table it reads from changes on a daily basis (I am working to get that changed). Because the table is created from Excel the column types change daily, even though the column names do not. (Why they did not use a template, I do not know). Thus the phone number columns can be either VARCHAR or FLOAT. That is where my conversion code comes in.
If I use the above conversion and it is FLOAT I get what I want, and it seems to work for VARCHAR columns also, but is it okay to use for VARCHAR to VARCHAR?

Thanks

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
There would be no side effects that I know of if you convert or cast to the same data type.
 
Thanks

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top