Forum Replies Created

Viewing 15 posts - 1,156 through 1,170 (of 2,458 total)

  • RE: Are the posted questions getting worse?

    -- TheTimeIs Script

    -- start script

    CREATE PROC TheTimeIs AS

    SELECT CREATED FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'TheTimeIs';

    GO

    EXEC TheTimeIs;

    DROP PROC TheTimeIs;

    GO

    -- end script

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Are the posted questions getting worse?

    Lynn Pettis (11/19/2015)


    Jeff Moden (11/19/2015)


    Eirikur Eiriksson (11/19/2015)


    So to recap, here are 9 different methods for getting the current time, any additions anyone?

    😎

    SELECT

    GETDATE()

    ,SYSDATETIME()

    ...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Unable to print the charindex of a special character of its 4th occurrence.

    Just for fun and practice:

    DECLARE @x varchar(100) = 'AB_CD_EF_GH_IJ';

    WITH L1 AS (SELECT N=1 FROM (VALUES (1),(1),(1),(1),(1),(1),(1),(1),(1),(1))X(x)), -- 10 rows

    iTally(N) AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) FROM L1...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: A Case FOR Cursors...

    Sean Lange (11/17/2015)


    Alan.B (11/16/2015)


    The Dixie Flatline (11/16/2015)


    Without using specific examples to test, it is hard to explain why set-based processing outperforms cursor-based code. ..."It depends" to coin a...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Are the posted questions getting worse?

    Brandie Tarvin (11/17/2015)


    Ed Wagner (11/17/2015)


    Brandie Tarvin (11/17/2015)


    Ed Wagner (11/17/2015)


    Lynn Pettis (11/16/2015)


    Ed Wagner (11/16/2015)


    Lynn Pettis (11/16/2015)


    And then you this type of question:

    ************(11/16/2015)


    How can i round off decimal number. E.g if i...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: A Case FOR Cursors...

    The Dixie Flatline (11/16/2015)


    Without using specific examples to test, it is hard to explain why set-based processing outperforms cursor-based code. ..."It depends" to coin a cliche. ...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Good Basic T-SQL Exercises

    I thought more people would jump on this. :Whistling:

    Anyhow I took a few minutes to throw some stuff together for you. Perhaps this will be helpful.

    USE tempdb

    GO

    /****************************************************************************************

    (1) Create Sample...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Getting previous month data when new year starts

    alex_martinez (11/14/2015)


    Thank you, I still a little fizz on this, can you give me an example. Thank you.

    I'm not at a PC so I can't test this but...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Whether my table is stored as heap or b-tree?

    Jeff beat me to it. Tables are either HEAPS or Clustered Tables (e.g. a table with a clustered index which means it's a B-Tree).

    I would add, you could run this...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Using the Stuff Function

    Luis Cazares (11/12/2015)


    Do you know what the stuff function does?

    https://msdn.microsoft.com/en-us/library/ms188043.aspx

    SELECT STUFF ( 'This is a lack of knowledge' , 11 , 7 , 'great' )

    Though STUFF is an insignificant and...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Using the Stuff Function

    This should get you started.

    http://www.sqlservercentral.com/articles/comma+separated+list/71700/%5B/url%5D

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Missing Index proposed by SQL Execution Plan

    But if you're in a hurry and cannot wait for enlightenment, I suggest you find and download sp_BlitzIndex

    +1 😉

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Missing Index proposed by SQL Execution Plan

    sgrimard (11/11/2015)


    Any suggestion on good books or site to learn how to create good index?

    SQL Server 2012 Query Performance Tuning (Expert's Voice in SQL Server) by Grant Fritchey is a...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Procedure to create schema defined XML from a set of tables

    MonkSup (11/10/2015)


    Thanks for your response. I've been digging around the MSDN documentation...

    Is OPENXML something I should look into?

    https://msdn.microsoft.com/en-us/library/ms187897(v=sql.110).aspx

    I can find plenty of examples for importing and creating structures for XML...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: SQL Pivot Table Nulls

    How about ISNULL? ISNULL(<whatever>,'') for blank values, ISNULL(<whatever>,0) to get a 0.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 1,156 through 1,170 (of 2,458 total)