Article View: bit.databases.mssql-l
Article #5Re: Re: query??
From: ricksql
Date: Thu, 04 Sep 2003 06:22
Date: Thu, 04 Sep 2003 06:22
90 lines
3352 bytes
3352 bytes
Dear Jens S��meyer, how do it in create procedure?. rick > > you have to put the strigs all together, bute till you don�t post some ddl > and exmplae data its not very easy to help you. The first thing, is to do > this query with a function that concas these values together: > > ---Untested, because of missing examples: > > DROP Function fn_Myfunc > > CREATE FUNCTION fn_Myfunc(@COL int) > RETURNS VARCHAR(30) > AS > BEGIN > DECLARE @W VARCHAR(30) > DECLARE @EXAM varchar(50) > SET @W = '' > SELECT @W = @W + CAST(examname AS VARCHAR(10)) + ' ' FROM temptable WHERE > studentID=@COL > SELECT @EXAM=examname FROM temptable WHERE studentID=@COL > If @EXAM IS NOT NULL > BEGIN > SET @W = LEFT(@W,LEN(@W)-1) > END > RETURN @W > END > GO > > SELECT StudentID,[P/F],dbo.fn_Myfunc(StudentID) as Exams > FROM temptable > > But for this, tables must be non temporary, because of working in a > function. > > HTH, Jens S��meyer. > > > #temptable (studentID,p/f,examid,examname): > > 1 p > > 2 f 100 bio > > 2 f 101 mTH > > 2 f 102 CHM > > 2 f 103 spts > > 2 f 104 LIT > > 2 f 107 geo > > 2 f 109 phys > > 2 f 110 eng > > 2 f 111 hist > > 3 p > > 4 f 100 bio > > 4 f 102 chm > > 4 f 109 phys > > 4 f 110 eng > > > > #tempResult: > > > > (studentid,p/f,1st,2st,3rd,4th,5th) > > 1 p > > 2 f bio math chm spts lit > > 3 p > > 4 f bio chm phys eng > > > > > > what query turns #temptable to #tempresult?. > > rick > > > > > > > > > > -- > > Sent by ricksql from yahoo in field com > > This is a spam protected message. Please answer with reference header. > > Posted via http://www.usenet-replayer.com/cgi/content/new > > -- Spam protected message from: Sent by ricksql from yahoo piece from com Posted via http://www.usenet-replayer.com/cgi/content/new
Technical Details
Message-ID:
<r.1062656564.1861663818@host-66-81-125-196.rev.o1.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.nacamar.de!news1.ip-mobilphone.net!news2.ip-mobilphone.net!u50415039@spawnkill.ip-mobilphone.netReferences:
<l.1062563763.1400665283@host-66-81-69-23.rev.o1.com> <#e36Z#dcDHA.4020@tk2msftngp13.phx.gbl>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 11301e,491a6121cd5fc1c6 X-Google-Attributes: gid11301e,public X-Google-Thread: f6611,491a6121cd5fc1c6 X-Google-Attributes: gidf6611,public X-Google-Thread: 104de1,491a6121cd5fc1c6 X-Google-Attributes: gid104de1,public X-Google-Thread: 107d2f,491a6121cd5fc1c6 X-Google-Attributes: gid107d2f,public X-Google-ArrivalTime: 2003-09-04 00:00:23 PST From: u50415039@spawnkill.ip-mobilphone.net (ricksql@yahoo.com) Sender: u50415039@spawnkill.ip-mobilphone.net Newsgroups: bit.databases.mssql-l,comp.databases.ms-sqlserver,microsoft.public.sqlserver,microsoft.public.sqlserver.programming Subject: Re: Re: query?? Date: Thu, 04 Sep 2003 06:22:43 GMT Lines: 89 Message-ID: <r.1062656564.1861663818@host-66-81-125-196.rev.o1.com> References: <l.1062563763.1400665283@host-66-81-69-23.rev.o1.com> <#e36Z#dcDHA.4020@tk2msftngp13.phx.gbl> NNTP-Posting-Host: 066.0081.000125.00196 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 - ur Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.nacamar.de!news1.ip-mobilphone.net!news2.ip-mobilphone.net!u50415039@spawnkill.ip-mobilphone.net