Forum Replies Created

Viewing 15 posts - 1 through 15 (of 217 total)

  • RE: distinct sum for an expression

    Thanks!

    I was wondering, do you know if it would be possible to combine both queries so that I get something like this?

    SELECT 'Jimmy' AS Person,'12345' As weaponId,1 AS isFinished, 2...

  • RE: distinct sum for an expression

    sharonsql2013 (2/1/2016)


    Should your Output have Alex = 2?

    No because it's the same weaponId. I only want to count isFinished once for each weaponId.

    Thanks

  • RE: Matrix report: Link column query to row query

    Thanks for the tip on creating a query to show data. Much better than what I had. 🙂

    I'm afraid I'm still a little lost though.

    So I have my query:

    SELECT

    ...

  • RE: simplifying a complicated delete statement

    Thanks. I tried joins, but I am not receiving the same number of rows as I am with the original query.

    I replace the delete with a select for testing:

    SELECT...

  • RE: Loop through an IN() clause?

    productionStarted should be tr.productionStarted

    partID should be tr.partID

    Thanks!

    ChrisM@Work (1/7/2016)


    There are some code gotcha's in your original query. Looking at the first CTE, and expanding the range of PartID to get a...

  • RE: Loop through an IN() clause?

    Thank you, but you are using 'u.testId' which comes from one of my CTEs.

    Sergiy (1/5/2016)


    You do not need all those CTE's.

    This simple query will do:

    DECLARE @PartID_List VARCHAR(8000)

    SET @PartID_List = '1,2,3,4,5,6,7,8,9,10,11,12'

    SELECT...

  • RE: Backup and Restore Plan

    Jeff Moden (12/16/2015)


    Personally, I'm a BIG fan of xp_CmdShell and I might be missing something but... I don't see you actually using it anywhere in your scripts.

    Oh ok, I was...

  • RE: help with updating database

    Ok I downloaded and installed Redgate but I don't really see how this will copy data from the production database to my development database. I can see how Redgate...

  • RE: ORDER BY not working

    Here is my table and query:

    /****** Object: Table [dbo].[pageList] Script Date: 09/15/2010 11:44:13 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[pageList](

    [userID] [int] NULL,

    [pageName] [nvarchar](255) NULL,

    [pageDate]...

  • RE: ORDER BY not working

    dates are stored in datetime format:

    2010-04-28 00:00:00.000

    2010-04-29 00:00:00.000

    2010-04-29 00:00:00.000

    2010-04-29 00:00:00.000

    2010-04-30 00:00:00.000

    2010-05-03 00:00:00.000

    2010-05-03 00:00:00.000

    2010-05-04 00:00:00.000

    2010-05-04 00:00:00.000

    2010-05-05 00:00:00.000

    2010-05-05 00:00:00.000

    2010-05-06 00:00:00.000

    2010-05-07 00:00:00.000

    2010-05-10 00:00:00.000

  • RE: ORDER BY not working

    Oh I see...thanks for BOL link.

    I tried using 101 instead of 103, and I still get a random order by.

    I also just tried doing ORDER BY pageDate, but that generated...

  • RE: ORDER BY with CASE statement

    Yes, I would like to be able to do this:

    ORDER BY

    CASE

    WHEN @SortSeq = 'asc' AND @SortOrder =...

  • RE: ORDER BY datetime help

    thanks! That worked!

  • RE: dynamic sql inside stored procedure?

    Oops...I definately don't want 2 resultsets!

    So I would rewrite it like this

    SELECT * FROM myTable

    Where Case

    WHEN @myVar = 1 THEN

    ...

  • RE: dynamic sql inside stored procedure?

    The queries are all the same except for various AND statements.

    So I guess I could do this?

    SELECT * FROM myTable

    WHERE 1 = 1

    select case @myVar

    WHEN 1 THEN

    ...

Viewing 15 posts - 1 through 15 (of 217 total)