Re: Odd pivot table type query

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 11/24/04

  • Next message: Vishal Parkar: "Re: "Length" in table design view"
    Date: Wed, 24 Nov 2004 13:06:53 +0530
    
    

    Shawn,
    There is no function as such which will do the things for you.

    You may try following approach using User defined function. But remember,
    this is not a documented method, so it can not be reliable under all
    cirumstances.

    CREATE FUNCTION EmpPhones (@ID INT)
    RETURNS VARCHAR(8000)
    AS
    BEGIN
      DECLARE @str VARCHAR(1000)
      SELECT @str = ISNULL(@str + ',', '') + cats
      FROM tab WHERE id = @ID
      RETURN (@str)
    END

    -- sample data / result set.
    if object_id ('tab') is not null
    drop table tab
    go
    create table tab(ID int,
    cats varchar(50))
    go
    insert into tab values(1 ,'1-001')
    insert into tab values(1 ,'2-002')
    insert into tab values(1 ,'3-003')
    insert into tab values(2 ,'1-011')
    insert into tab values(3 ,'1-012')
    insert into tab values(3 ,'2-022')
    go
    --And then you would call this UDF from within a SELECT statement, as
    follows:
    select distinct id,dbo.empphones(id) 'comma seperated value' from tab

    -- 
    Vishal Parkar
    vgparkar@yahoo.co.in | vgparkar@hotmail.com
    

  • Next message: Vishal Parkar: "Re: "Length" in table design view"

    Relevant Pages

    • A source file de-tabifier for you
      ... *transform* one tab setting to another; thus, you can write your code with ... void do_line; ... int reset_on_com = FALSE; ... char **argv; ...
      (alt.comp.lang.learn.c-cpp)
    • Re: newbie question
      ... int main{ ... The problem is that some news readers clients (or is it some news ... server, I don't know) strip the TAB and consequently, your code appears ...
      (comp.lang.c)
    • Re: exercise 1-20 K&R
      ... of blanks to space to the next tab stop. ... int counter, c; ... character count for the current line, ... Tab stops are at the same character number (modulo TABSIZE) throughout ...
      (comp.lang.c)
    • Re: I dont quite understand this exercise...
      ... >ask the user/get and set a variable, say n, and replace all tabs with n ... A text file containing some tab characters. ... if N is 4 and the original file is: ... int jj = 0; ...
      (comp.lang.c)
    • [patch 1/14] s3c2412/s3c2413 support
      ... +s3c_lookup_cpu(unsigned long idcode,int alt) ... struct cpu_table *tab; ... int count; ...
      (Linux-Kernel)