Forum Replies Created

Viewing 15 posts - 4,516 through 4,530 (of 7,613 total)

  • RE: Need help constructing this SQL Statement, against one table only (table with three columns)

    You need a WHERE condition on the SELECT from the CTE:

    ...

    SELECT log1.ID,

    log1.STime StartTime,

    log2.STime EndTime,

    DATEDIFF(second, log1.STime,...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need to negate a where clause

    For performance reasons, you should never use ISNULL in a WHERE (or JOIN) clause, because you'll prevent possible index seeks on the underlying column. While the code below is...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Number VS Letter

    I'd at least compare the performance of the straightforward brute-force method:

    SELECT

    word AS original_string,

    CASE WHEN SUBSTRING(word, 01, 1) LIKE '[0-9]' THEN SUBSTRING(word, 01,...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need help constructing this SQL Statement, against one table only (table with three columns)

    Something like this might (or might not) perform better, if you need to calc time diff for just those two steps:

    SELECT lst.SNum, lst.SOpDesc, lst.STime,

    CASE WHEN...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How to reduce Huge Log File size

    Jeff Moden (12/25/2015)


    ScottPletcher (12/25/2015)


    Jeff Moden (12/24/2015)


    You've confused me a bit, Scott. First you say that 16 VLFs for a 1GB logfile is too low and then you explain using...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Cursor or special select statement?

    SELECT c.Cust#, c.Name, c.Address, --c....

    STUFF(

    CASE WHEN cd.Monday = 1 THEN ',Mo' ELSE '' END +

    CASE WHEN cd.Tuesday =...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: create stored procedure with if condition

    baiju krishnan (12/25/2015)


    when i tried to execute your code following error shown

    Msg 8117, Level 16, State 1, Procedure Sp_Login, Line 19

    Operand data type bit is invalid for max operator.

    Then we'll...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How to reduce Huge Log File size

    Jeff Moden (12/24/2015)


    You've confused me a bit, Scott. First you say that 16 VLFs for a 1GB logfile is too low and then you explain using even fewer VLFs...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How to use 'like' in a query

    Since Transaction_Date contains the time, a query coded like this:

    Activity.Transaction_Date BETWEEN '20151130' and '20151201'

    Would return rows from 12/01/2015 at exactly midnight (if there were any). But that wouldn't really...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How to use 'like' in a query

    select Name.ID, Name.FULL_NAME, Name.FULL_ADDRESS, Name.EMAIL, Activity.ID, Activity.ACTIVITY_TYPE, activity.SOURCE_CODE, activity.TRANSACTION_DATE, Activity.DESCRIPTION

    from Name

    INNER JOIN Activity

    ON Name.ID=Activity.ID

    where Activity.Activity_Type = 'CALL' and SOURCE_CODE = 'BWILSON' and

    Activity.Transaction_Date >= '20151130' and

    Activity.Transaction_Date < '20151201'

    order by Name.ID,...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How to use 'like' in a query

    WHERE Transaction_Date >= '20150101' AND Transaction_Date < '20160101'

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: create stored procedure with if condition

    Your code doesn't match your description. Here's code that matches your description.

    For efficiency, I've limited it to a single SELECT from the login table.

    CREATE PROCEDURE [dbo].[Sp_Login]

    @uname nvarchar(20),

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How to reduce Huge Log File size

    Jeff Moden (12/23/2015)


    ScottPletcher (12/23/2015)


    Jeff Moden (12/22/2015)


    WhiteLotus (12/21/2015)


    Sounds good ..I also notice that all databases autogrowth option are 10% . Should I change all of them ?

    If the initial size was...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Converting and Assigning a Date Variable

    The internal format of date (or datetime or other temporal data type) is not the same as the character format we humans use. In fact, it's just an integer....

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Trigger doesnot update last record

    Not sure why the "last row" wasn't affected, since that trigger's going to update every row, which you don't want. You need to join to the inserted pseudo-table to...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 15 posts - 4,516 through 4,530 (of 7,613 total)