Forum Replies Created

Viewing 15 posts - 106 through 120 (of 239 total)

  • RE: How to Convert a Row in Columns

    Try something like this:

    --turn a wide table into a narrow table

    declare @Table table (col1 int, col2 int, col3 int)

    insert @Table values (1, 2, 4)

    select 'col1' as colname, col1 as colvalue

    from...

  • RE: How to convert a Row into Columns

    Try this:

    declare @Table table (col1 int, col2 int, col3 int)

    insert @Table values (1, 2, 4)

    select 'col1' as colname, col1 as colvalue

    from @Table

    union all

    select 'col2' as colname, col2

    from @Table

    union...

  • RE: limit to # of cols can be used with columns_updated() function?

    I don't know of a maximum but it may be related to the fact that columns_update() returns a bitmask and that 2^104 is quite a large number.

    I would consider changing...

  • RE: Update Statement

    Try this:

     

    UPDATE b

    SET fiscal_month_name = p.month_name

    FROM tbl b

    INNER JOIN period p

    ON B.dt BETWEEN p.from and p.to and B.FISCAL_DAY = 15

     

  • RE: Flatten a table

    Since you are using a front end, why not just return the list to the client and concatenate them in the ASP page?

  • RE: Find duplicate records

    Try this:

    declare @UserAddr table (user_fk int, addr_fk int)

    insert @UserAddr values(780579, 102261)

    insert @UserAddr values(780579, 102263)

    --return just the user_fk

    select user_fk

    from @UserAddr

    group by user_fk

    having count(*)>1

    --return just the user_fk and addr_fk

    select ua.*

    from @UserAddr...

  • RE: Converting datatypes in a Stored Procedure

    The statement 'SELECT DataTable = @DataTableID' is not valid syntax.

  • RE: ISQL Export

    Try this:

    OSQL /U SA /P password -S localhost -d master /i MYQUERY.SQL /o MYRESULTS.TXT -n -h-1

    Note that you should use OSQL instead of ISQL and there is no need to...

  • RE: how to find duplcates in a cosecutive period of time

    What about 5/4, 5/5 & 5/6 and 5/5, 5/6 and 5/7

    This may work if they are to be included:

    declare @Table table (dt datetime, nbr int)

    insert @Table values ('1/1/05', 0)

    insert @Table...

  • RE: How to delete a record while a foriegn key is there

    I agree with Ryan, why not just do an UPDATE on the table?

  • RE: Can''''t get this query to work

    Note that in my query, there is no subquery.  This should help the performance.

  • RE: Convert rows into columns

    Try this and add the remaining months:

    declare @Table table (ID int, Jan int, Feb int, March int, April int)

    insert @Table values (1, 2, 4, 6, 8)

    insert @Table values (2, 3,...

  • RE: how to get consective dates from a table?

    Try this without using views:

     

    declare @table table

    (ID_VAL INT identity(1,1),

     Date_Field Datetime

    )

    insert into @table values ('02/12/2006')

    insert into @table values ('02/13/2006')

    insert into @table values ('02/14/2006')

    insert into @table values ('02/15/2006')

    insert into @table values ('02/17/2006')

    insert...

  • RE: Can''''t get this query to work

    This works, with some changes to the query and criteria to test it:

    declare @charts table (patientno int, lastname varchar(20), firstname varchar(20), sex char(1), race char(2), loc char(3), docid int,...

  • RE: DELETE duplicate records - need a simpler Solution

    You can try something like this:

    declare @Employee Table (EmpName  varchar(10), EmpDesignation char(3))

    insert @Employee values ('Muthu K', 'ITA')

    insert @Employee values ('Muthu K', 'ITA')

    insert @Employee values ('Muthu K', 'ITA')

    insert @Employee values ('Muthu...

Viewing 15 posts - 106 through 120 (of 239 total)