Forum Replies Created

Viewing 15 posts - 781 through 795 (of 2,894 total)

  • RE: Is there a loop in this query

    nigelrivett (12/11/2012)


    This does something similar but without the correlated subquery.

    Depends on your data as to whether it is any better

    SELECT AA.[Country Code],

    SUM(extendedamount) AS Amount

    FROM dbo.AllActiveAuthorised AS AA

    WHERE dispatcheddate >= CAST('20121101'...

  • RE: Is there a loop in this query

    No, there are no LOOPs here.

  • RE: ORDER BY Should be same as my input in IN()

    You cannot force the order as per list in IN.

    You should consider re-factoring your query.

    One of the ways:

    SELECT t.*

    FROM @T t

    JOIN (VALUES (1,'XYZ'),(2,'AAA'),(3,'PQR')) lst(rn,name)

    ON lst.name= t.name

    ORDER by lst.rn

  • RE: Need help getting totals by ZipCode

    sanket kokane (12/10/2012)


    please don't stop posting your questions..

    Just follow some rules ..People are happy to help you here

    Don't take anything Personally 🙂

    Especially such default rude and non-constructive answers from...

  • RE: Making groups using a separator line

    Phil Parkin (12/11/2012)


    WolfgangE (12/11/2012)


    You misunderstood. I cannot use the house numbers in my query. That was just to show how the result should be. I have not only 1...

  • RE: Making groups using a separator line

    I'm glad to help. You are welcome!

  • RE: Making groups using a separator line

    The problem with your posted sample is lack of details. Would be really great if you could provide better DDL. What is PK of your table? What really makes your...

  • RE: error in stored procedure

    Sean Pearce (12/11/2012)


    ALTER PROCEDURE [dbo].[usp_delete]

    @tablename sysname,

    @pid int,

    @pidname varchar(10)

    AS

    DECLARE @sql NVARCHAR(MAX),

    @Params NVARCHAR(MAX);

    SELECT@sql = 'DELETE FROM [' + @tablename + '] WHERE ' + @pidname + ' = @pid;',

    @Params = '@pid INT';

    EXEC...

  • RE: identifying records in the same table

    nigelrivett (12/11/2012)


    select id

    from tbl

    where type in ('A','B')

    group by id

    having count(distinct type) <> 2

    That is good, but only will work if one of the types is missing...

  • RE: identifying records in the same table

    Provided sample is very basic, but should give an idea how to do what you want:

    declare @sample table (id int, [type] char(1))

    insert @sample select 1,'A'

    insert @sample select 1,'B'

    insert @sample...

  • RE: How to use NOT IN or Not Exist custom in Datetime?

    Hope that following should help you:

    SELECT tf.EmpNo, tf.ChkDate

    FROM filesTA tf

    WHERE tf.ChkDate BETWEEN '20121001' AND '20121005'

    AND NOT EXISTS (SELECT 1 FROM SalaryDay2 sd2

    ...

  • RE: Architecture Diagram

    ...

    In short, I need officially accepted "SQL Architecture diagram 2012".

    I'm just guessing, but if such one would exist, google search would return it straight away...

  • RE: Exercises in t-SQL

    Continuous discussion on this thread, kind of shows that people has nothing much to do...

    :hehe:

    I do agree with few different points of different posters...

    I guess if such question is asked...

  • RE: CASE WHEN Statement when creating a VIEW

    ... does it do one condition and then drop to the CASE...END statement after satisfying one of the conditions?

    That is correct.

  • RE: IF EXISTS Logic

    Why are you trying to use dynamic sql. It's look like you need full outer join:

    SELECT ISNULL(t.Column_Name, v.Column_Name) AS Column_Name

    ...

Viewing 15 posts - 781 through 795 (of 2,894 total)