September 4, 2013 at 10:25 am
If you had this:
create table A
( id int
);
go
create table b
( mychar varchar(20)
);
go
insert a select 12345
insert a select 23456
insert b select '0012345'
insert b select '00012345'
Show how you can compare or join on these fields. Feel free to add a couple other fields for display.
Explain the issues with converting to integers, or pattern conversions to varchar
September 4, 2013 at 3:35 pm
Steve Jones - SSC Editor (9/4/2013)
If you had this:create table A
( id int
);
go
create table b
( mychar varchar(20)
);
go
insert a select 12345
insert a select 23456
insert b select '0012345'
insert b select '00012345'
Show how you can compare or join on these fields. Feel free to add a couple other fields for display.
Explain the issues with converting to integers, or pattern conversions to varchar
Can I include the first step which would be "Hunt down the designer of this mess and feed him large quantities of high velocity pork chops?" 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
September 4, 2013 at 6:47 pm
No, but feel free to do a design article that covers a few things about why you wouldn't do this. Or how you might refactor this mess.
January 31, 2014 at 11:10 am
bump
April 10, 2014 at 6:50 pm
I'd be interested in taking this on. The quick example of joining on converted values would illustrate implicit conversions and the suboptimal execution plans that go along with it.
Some solutions can include: adding a new column to the table to handle a like data type value, creating an indexed temp table populated with the casted value, and some tips on designing better tables such that this doesn't happen in the first place---or it can be fixed later with a change to the table's design.
April 10, 2014 at 8:01 pm
Take it, Ed, but focus on one solution. I'd rather have focused articles than one that tries to solve all possibilities. If you'd like to do a series, then you can do a few that look at different solutions and we can group them together.
April 11, 2014 at 8:38 am
Sounds good, thanks!
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply