Forum Replies Created

Viewing 15 posts - 1,696 through 1,710 (of 2,458 total)

  • RE: Split row on two

    I think this should do the trick:

    WITH t1 AS

    (

    SELECT * FROM #Test1

    CROSS APPLY (VALUES ('Actual'),('Budget')) ab(RecType)

    )

    SELECT

    RecType,

    recID, MyDate,

    CASE...

    "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: Convert Datetime to TIME

    1. The TIME datatype does not exist in 2005 (it was introduced it 2008)

    2. Your query appears to have been cut off.

    "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 WHILE to avoiding Cursor

    It's also worth noting that sometimes a cursor performs much better than a loop (e.g. the WHILE logic that you are using).

    That said, and has already been mentioned, you...

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

    DECLARE @i tinyint = 1;

    WHILE @i <= 5

    BEGIN

    If exists (select fieldID from #tmploginfo where status <> 0

    group by fieldID

    having count(*) > 0)

    begin

    backup log rdb to disk = N'C:\rdb1.trn'

    End;

    SET...

    "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: DISTINCT use on views problem

    mattech06 (3/19/2015)


    Hi,

    I seem to have an odd situation.

    I have a view that when created holds about 40k of rows.

    when I use

    SELECT DISTINCT RefTypeWord FROM vw_Referrals where ClientRef = 'EPS' 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

  • RE: DISTINCT use on views problem

    twin.devil (3/20/2015)


    All the question you have asked means you yet to get to know the working of sql server. i have share you some links to understand what is what....

    "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 a subquery

    Sorry, I completely misunderstood your requirement. I will look at this again later today.

    "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: T-SQL and CLR types for return value do not match

    You're returning a Table Valued Function so you need to return a IEnumerable (Note: CLR Table-Valued Functions)

    I have not written a CLR in a while but I think that

    public...

    "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 a subquery

    If by "remove log files" you want to delete the records in tempsysdatabase where the names are: rdb_log3 and rdb_log4

    This should work:

    DELETE FROM #tempsysdatabase

    WHERE name IN

    (

    select #tempsysdatabase.name, count (#temploginfo.FieldId) as...

    "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: Grey out a paramter based on the value of another parameter?

    jbalbo (3/19/2015)


    Hi Alan

    Thanks for getting back so quick.

    I get most if it, just a bit confused on the dataset part.

    Here is the dataset I am using, if you could incorporate...

    "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: Grey out a paramter based on the value of another parameter?

    I don't believe that you can disable/enable a parameter (I could be wrong but I am pretty sure that you can't).

    One thing you can do is this:

    You have a parameter...

    "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 a field in the middle ??

    These problems are fun. If the data format is always the same (##/##/####) you could also do this:

    DECLARE @TestString VARCHAR(50)

    SET @TestString = 'LastName, FirstName (DOB: 01/01/1900)'

    SELECT SUBSTRING(@TestString, PATINDEX('%[0-1][1-9]/%', @TestString),10);

    "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: Inline vs. Multi-Statement Table-Valued function, Temp Tables vs. CTEs?

    Had a second to kill. I put together a test to demonstrate why multi statement TVFs (mTVF) are terrible

    Using TempDB (a DB I know you have) this code will create...

    "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: Microsoft and R

    Great article. There is a good article about this at on SQLMag.com. This is huge news indeed and is all the rage where I work.

    "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: Hide field from Tablix based on query field valu

    PSB (3/18/2015)


    Hi,

    I have a report where there are fields like Field1,Field2,Field3,Field4 etc . In the report query there is a field named IsParentAccount . If it is 0 then 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

Viewing 15 posts - 1,696 through 1,710 (of 2,458 total)