kylewolfe — 2011-04-07T11:33:11-04:00 — #1
I want to create a new column that has a default value of the primary key in a varchar(10) format. Hows this done?
r937 — 2011-04-07T12:10:08-04:00 — #2
it's not done -- you cannot assign a default value of another column
why not just convert the value when you run a SELECT?
or, if you're gonna do it relentlessly on every SELECT, why not set up a view which has the extra column incorporated?
anthonysterling — 2011-04-07T12:56:17-04:00 — #3
You're duplicating data though, why would the pk value not suffice?
kylewolfe — 2011-04-07T13:54:12-04:00 — #4
Our large dataset needs compared regularly against two seperate databases, One stores the pk as a double, the other as a string (wonderful right?) Our local copy of the dataset is only a small portion of the whole system so storing both types of primary keys for joining to both seemed useful.
anthonysterling — 2011-04-07T14:10:11-04:00 — #5
Ah, I see. A view, as R937 states, sounds like it could be useful here then.
kylewolfe — 2011-04-07T14:25:56-04:00 — #6
Ah nice. Had not seen or heard of views before now. Thanks for that pointer.