Forum Replies Created

Viewing 15 posts - 241 through 255 (of 683 total)

  • RE: how to join two tables having no common row and no primary key in any of the two table

    How's this?

    --Preparation

    declare @t1 table (start_date_time datetime, ani varchar(20), dialed_digits varchar(20), actual_dur int, rounded_dur int, cost money)

    insert @t1

    select '03/01/2008 00:05:57', '629172162448',...

  • RE: SUM and Sorting

    Any of these will do the sorting...

    SELECT PERSON, SUM(T_VOTES) AS TOTAL

    FROM VOTING

    GROUP BY PERSON

    ORDER BY SUM(T_VOTES)

    SELECT PERSON, SUM(T_VOTES) AS TOTAL

    FROM VOTING

    GROUP BY PERSON

    ORDER BY 2

    SELECT PERSON, SUM(T_VOTES) AS TOTAL

    FROM VOTING

    GROUP...

  • RE: Find the number of tables used by a procedure

    Andras Belokosztolszki (4/10/2008)


    That's useful - thanks Andras.

  • RE: Find the number of tables used by a procedure

    I don't know exactly, but you can probably do something along the lines of...

    select * from information_schema.tables

    where table_type = 'base table' and table_name in (

    select distinct...

  • RE: Creating & Executing a Funtion

    you cannot EXEC a function

    That's not strictly true. This works...

    DECLARE @lcPostArea VARCHAR(4)

    EXEC @lcPostArea = dbo.PostArea @lcPostcode = 'HX1'

    SELECT @lcPostArea

    Although the "SELECT dbo.PostArea('HX1')" is of course shorter.

  • RE: Creating & Executing a Funtion

    Your while loop needs a begin..end around the set statements...

  • RE: Need some help with a Self join

    Hi all,

    I've just caught up with the thread.

    This would be my latest try based on the discussions...

    ; with x as (select ChildNo, ChildRev from #Children where ParentNo = @ParentNo and...

  • RE: Need some help with a Self join

    Like this?

    --Create temporary table that holds Parent and Children records.

    IF OBJECT_ID (N'tempdb..#Children', N'U') IS NOT NULL

    DROP TABLE #Children;

    CREATE TABLE #Children (ParentNo VarChar(50), ParentRev Int, ChildNo VarChar(50), ChildRev Int)

    --Insert test data...

  • RE: count instances using sql:variable

    I think my timing may be a little off, but anyway...

    declare @t table (x xml)

    insert @t

    select '<a link="x" />'

    union all...

  • RE: For XML generic list deserialize

    I think my timing may be a little off here, but anyway.

    This is pretty inelegant, but it is one way...

    create table Table1 (ID int)

    insert Table1

    ...

  • RE: Replace Count* with 0 if Null

    Or this?

    IF EXISTS (SELECT * FROM dbo.table1 WHERE school = 'xxxxxxxxxxxxx')

    SELECT COUNT(*) AS thecount

    FROM ...

  • RE: Updating All Rows

    A CASE statement will allow you to do more complicated stuff. Your exact request can be done without...

    update Employees set FullName = FirstName + ' ' + LastName

  • RE: Update XML Element - Syntax issues

    Easy...

    SET @x.modify('delete //xdata/project/store_number/@xsi:nil')

    This is XML DML, and you can read about it in BOL or online...

    http://msdn2.microsoft.com/en-us/library/ms177454.aspx

  • RE: Update XML Element - Syntax issues

    Like this?

    declare @x xml

    set @x = '<xdata>

    <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <name>bob</name>

    <store_number xsi:nil="true" />

    </project>

    </xdata>'

    SET @x.modify('insert text{"1"} as first into (//xdata/project/store_number)[1]')

    select @x

    --result

    /*

    <xdata>

    ...

  • RE: Beginning Database Design - Spot the Flaws

    jomobono (11/21/2007)


    Maybe you could write a book on it jomobono 😀

    The kitchen analogy is a good one to illustrate another point. Often what the customers wants will be established (using...

Viewing 15 posts - 241 through 255 (of 683 total)