Click here to Skip to main content
15,902,189 members
Home / Discussions / Database
   

Database

 
GeneralRe: Concat Strings SQL Questions Pin
Braulio Dez12-Sep-03 2:18
Braulio Dez12-Sep-03 2:18 
Hi,

I found a solution with SQL Server, a bit ugly T-SQL thing...

<br />
CREATE TABLE foo<br />
 (c1 VARCHAR(10) NOT NULL, c2 VARCHAR(10) NOT NULL CHECK (c2 NOT LIKE<br />
'%,%'), PRIMARY KEY (c1,c2) )<br />
<br />
INSERT INTO foo VALUES ('Tom','Car')<br />
INSERT INTO foo VALUES ('Tom','House')<br />
INSERT INTO foo VALUES ('Tom','Plane')<br />
INSERT INTO foo VALUES ('Tom','Boat')<br />
INSERT INTO foo VALUES ('Jim','House')<br />
INSERT INTO foo VALUES ('Jim','Boat')<br />
<br />
CREATE TABLE Results<br />
 (c1 VARCHAR(10) PRIMARY KEY, c2list VARCHAR(100) NOT NULL)<br />
<br />
INSERT INTO Results<br />
 SELECT c1,MAX(c2) FROM foo GROUP BY c1<br />
<br />
WHILE @@ROWCOUNT>0<br />
 UPDATE Results<br />
  SET c2list =<br />
  (SELECT MAX(c2)<br />
   FROM foo<br />
   WHERE foo.c1 = Results.c1 AND<br />
    foo.c2<LEFT(c2list,CHARINDEX(',',c2list+',')-1))<br />
   + ', ' + c2list<br />
  WHERE EXISTS<br />
  (SELECT *<br />
   FROM foo<br />
   WHERE foo.c1 = Results.c1 AND<br />
    foo.c2<LEFT(c2list,CHARINDEX(',',c2list+',')-1))<br />
<br />
SELECT * FROM Results<br />
<br />

QuestionSQL: How to create a 1:1 relation? Pin
King_of_Queens10-Sep-03 22:09
King_of_Queens10-Sep-03 22:09 
AnswerRe: SQL: How to create a 1:1 relation? Pin
Mike Dimmick12-Sep-03 0:51
Mike Dimmick12-Sep-03 0:51 
Generaldatabase Pin
ranjjj10-Sep-03 19:01
ranjjj10-Sep-03 19:01 
GeneralRe: database Pin
PengFeidu11-Sep-03 2:18
PengFeidu11-Sep-03 2:18 
Generalquestion about OLEDB Pin
ashxly10-Sep-03 15:34
ashxly10-Sep-03 15:34 
GeneralRe: question about OLEDB Pin
Steve S11-Sep-03 2:04
Steve S11-Sep-03 2:04 
GeneralRe: question about OLEDB Pin
ashxly11-Sep-03 20:01
ashxly11-Sep-03 20:01 
GeneralNew version of SQL Server "Yukon" Pin
Nino_110-Sep-03 13:41
Nino_110-Sep-03 13:41 
GeneralRe: New version of SQL Server &quot;Yukon&quot; Pin
Tom Archer12-Sep-03 11:15
Tom Archer12-Sep-03 11:15 
GeneralRe: New version of SQL Server &quot;Yukon&quot; Pin
Mike Epprecht13-Sep-03 5:45
Mike Epprecht13-Sep-03 5:45 
Generalfilling a dataset; changing some data of the dataset without db-connection Pin
wolfschinnerl10-Sep-03 9:30
wolfschinnerl10-Sep-03 9:30 
GeneralRe: filling a dataset; changing some data of the dataset without db-connection Pin
Arjan Einbu12-Sep-03 10:42
Arjan Einbu12-Sep-03 10:42 
GeneralBatch Update performance Pin
WoonLeng9-Sep-03 16:59
WoonLeng9-Sep-03 16:59 
QuestionHow to bind in the Access Import Wizard Pin
King_of_Queens9-Sep-03 2:33
King_of_Queens9-Sep-03 2:33 
AnswerRe: How to bind in the Access Import Wizard Pin
Steve S9-Sep-03 6:19
Steve S9-Sep-03 6:19 
Generaldb schema required! help needed urgently Pin
rohitit6-Sep-03 10:45
rohitit6-Sep-03 10:45 
GeneralSP vs. View Pin
Not Active5-Sep-03 6:01
mentorNot Active5-Sep-03 6:01 
GeneralRe: SP vs. View Pin
Mark Conger5-Sep-03 6:14
Mark Conger5-Sep-03 6:14 
GeneralRe: SP vs. View Pin
Not Active5-Sep-03 6:42
mentorNot Active5-Sep-03 6:42 
Generalreboot the sqlserver Pin
yyf5-Sep-03 3:23
yyf5-Sep-03 3:23 
GeneralRe: reboot the sqlserver Pin
Terry Denham5-Sep-03 4:19
Terry Denham5-Sep-03 4:19 
GeneralMaster-Detail Question! Pin
EastDragon4-Sep-03 16:50
EastDragon4-Sep-03 16:50 
GeneralSQLDMO Pin
yyf3-Sep-03 8:53
yyf3-Sep-03 8:53 
GeneralRe: SQLDMO Pin
Terry Denham5-Sep-03 4:30
Terry Denham5-Sep-03 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.