Featured post
sql server - parsing comma seperated values in MS-SQL (no csv or such) -
i use closed source commercial application uses ms-sql database. regularly have query database myself various purposes. means table , database design fixed, , can't @ all. have live it. have 2 tables following layouts (abstracted, not discredit software/database designer)
t1: id (int), att1(varchar), att2(varchar), .... attx(varchar) t2: id (int), t1_ids(varchar)
now contents of t1_ids
(shudder) comma separated list of t1 id's. (for example 12, 456, 43, 675, 54). want (you guessed it) join 2 tables.
fortunately me, these small tables, , don't care performance in terms of complexity @ (could o(n^m)
far care).
ideally make view joins these 2 tables. don't have requirements inserting or updating, select statements. easiest , clearest (in terms of maintainability) way this?
to first , last use this:
select * t1 join t2 on '%,' + t1.id + ',%' ',' + t2.t1_ids + ','
it doesn't matter if t2.t1_ids start or end . valid values enclosed commas.
- Get link
- X
- Other Apps
Comments
Post a Comment