Forum Replies Created

Viewing 15 posts - 5,701 through 5,715 (of 7,613 total)

  • RE: Is there a way to enforce the use of a where clause in a select?

    Alexander Suprun (10/16/2014)


    Create a job which runs every 5 seconds and KILL the processes of specific user(s) where program_name is 'Microsoft SQL Server Management Studio - Query' and that reached...

    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: Significant performance dropping when use CASE statement

    From a purely performance stand-point, we'd almost certainly want to process Countries prior to it being JOINed:

    SELECT A.City_Name, B.Country_Code, B.Country_Area

    FROM Cities A

    INNER JOIN (

    SELECT Country_Code,...

    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: linked server - GO or no GO ??

    The GO separates the code into "batches". SQL parses and prepares an execution plan separately for each batch.

    Thus, without the GO, when SQL parses the query below...

    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: Adding two month

    kd11 (10/16/2014)


    Thanks for your suggestion, it help. Using that statement you provided, if I want to subtract -7 day or 1 week in addition could I just add...

    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: Split string to show only customer

    I'd think you'd definitely want to use LTRIM() and RTRIM() to make sure you get rid of extraneous spaces. I added ISNULL(NULLIF(...)...) just in case there isn't a dash...

    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: Adding two month

    If you can live with only a three-char month, you can remove the STUFF() function. If you need to have the full month name, you'll need the STUFF() part...

    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 random are constraint names?

    I admit, I name all constraints myself, including DEFAULTs, even though for DEFAULTs that may be deprecated.

    CREATE TABLE Theory (

    Id int identity(1,1) CONSTRAINT Theory__PK primary key,

    Data varchar(20),

    LogDate datetime CONSTRAINT Theory__DF_LogDate...

    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: extract number from string

    Do you have some type of id or other unique/key value on the row?

    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: With & Without Nested Loops (inner join) for Select statement which is the more performance?

    I agree with others, particularly on ISNULL(). In fact, there's a simple, very easy to remember rule:

    NEVER use ISNULL() in a WHERE or JOIN clause.

    If, as is typical, the...

    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 check latest SP is on server

    You could even DROP and (re)CREATE the procedure as long as you re-added the extended procedure with the version number after the CREATE.

    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 check latest SP is on server

    Staggerlee (10/14/2014)

    Is there a way via T-SQL to check or read information from a stored procedure? Ie, could I add a comment with a build number in it?

    I suggest...

    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: check varchar column for values that are only numeric - HOW

    I suggest a different method to avoid 2 or more decimal points:

    AND CASE

    ...

    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: extract number from string

    Jeff Moden (10/14/2014)


    It'll be interesting when an actual vendor name also contains dashes. 😛

    In that case, presumably we would search first for a digit only, "%0-9%", then do the search...

    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: extract number from string

    SELECT Fulltext, Contract2,

    Substring(Contract2, Contract3_Start, Contract3_Length) AS Contract3

    FROM (

    SELECT Fulltext From [Sonae].[dbo].[Images_Local]

    ) AS test_data

    cross apply (

    SELECT Substring(FullText, PATINDEX('%Contrato%',FullText), 50) as Contract2

    ) as...

    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: extract number from string

    SELECT Fulltext, Contract2,

    Substring(Contract2, Contract3_Start, Contract3_Length) AS Contract3

    FROM (

    SELECT 'Contrato Promocional 2010-241772 Descrico CDR TD' AS Fulltext UNION ALL

    ...

    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 - 5,701 through 5,715 (of 7,613 total)