Forum Replies Created

Viewing 15 posts - 1,876 through 1,890 (of 2,458 total)

  • RE: subquery???

    I'm thinking something like this...

    WITH

    scores(ID, creationdate, score, MCC) AS--SAMPLE DATA

    (

    SELECT 1, '2014-08-02', 30, 7422 UNION ALL

    SELECT 2, '2014-08-03', 40, 7422 UNION ALL

    SELECT 3, '2014-08-01', 100, 7500 UNION...

    "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: SELECT lento en una tabla de 9000 filas

    It looks like John beat me to it, if you can post a query plan that would be a great help - see: How to Post Performance Problems[/url]

    "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: I'm new to SQL development..

    I would second both recommendations and add that you can't go wrong with any Itzek ben-Gan book.

    Learn what a tally table is; that has changed my career.

    This site...

    "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: SubstringIndex

    ... I was thinking, using the logic in my previous post you could create a dbo.SubstringBeforeSSI function (examples included in the code)...

    ALTER FUNCTION dbo.SubstringBeforeSSI

    (

    @string varchar(1000),

    @substring varchar(100),

    @substring_index tinyint

    )

    /*

    DECLARE @string varchar(1000)='10.0.1600.22',

    @searchPattern varchar(100)='.',

    @substring_index...

    "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: SubstringIndex

    This wont perform as well as what Eugene posted but is a solid, set-based way to solve this problem dynamically...

    Using my Ngrams8k function:

    ALTER FUNCTION [dbo].[nGrams8K]

    (

    @string VARCHAR(8000),

    @n TINYINT,

    @pad BIT=0

    )

    /*--

    Created by:Alan Burstein

    Created...

    "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: Need help in query

    Another Approach:

    ;with

    CurrentResutSet(Period, Sense, mt, Total) AS

    (

    select '2014_S27', 'CPT', 1, 215 union all

    select '2014_S27',...

    "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: Need help in query - urgent plz

    As Louis said, DDL and what you have tried will help us help you faster. That said, I think you are looking for this:

    WITH

    your_data AS

    (SELECT *

    FROM (values ('ClassA',10001,'Y','Eligible',1,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: How do I handle transactional replication when moving the Subscriber (shutdown for a day and bring online)

    dagnea (9/16/2014)


    ...he insisted that the log file on the publishing database will not get truncated and will grow until the stopped subscription is started and the subscriber synched.

    Does this make...

    "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: Query help to find total

    A couple variations (these will get you the same query plan as what rxm posted).

    SELECT isnull(cast(id as varchar(12)),'Total'), sum(cnt)

    FROM @rollup

    GROUP BY id with rollup;

    or...

    -- since we're only...

    "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: Splitting Strings Based on Patterns

    Jeff Moden (9/12/2014)


    fregatepllada (9/12/2014)


    Dwain you do not need CLR to use regex 🙂

    There is an old way to call Vbscript library

    From t-SQL code 😉

    sp_OA???

    I suspect they were talking about:...

    "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: Language Translation in SSRS

    :Whistling:

    "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: Select Unique Customers per month for last 2 years..

    Sean Lange (9/11/2014)


    Alan.B (9/10/2014)


    months as

    (

    select 1 as MoNo, 'January' as Mo union all

    select 2 as MoNo, 'February' as Mo union all

    select 3 as MoNo, 'March' as Mo union all

    select...

    "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: Select Unique Customers per month for last 2 years..

    months as

    (

    select 1 as MoNo, 'January' as Mo union all

    select 2 as MoNo, 'February' as Mo union all

    select 3 as MoNo, 'March' as Mo union all

    select 4 as MoNo,...

    "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: SSMS 2012 appears to be very buggy

    I love SSMS 2012 and have not had any of the issues you describe. I'd reinstall or repair ssms.

    "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: Does replication replicate index rebuild ?

    SQL Guy 1 (9/10/2014)


    Hi all.

    We have transactional replication. We have a index rebuilding job on publisher, but subscriber is still highly fragmented.

    Should we create defragmentation job on subscriber, or...

    "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,876 through 1,890 (of 2,458 total)