Forum Replies Created

Viewing 15 posts - 2,071 through 2,085 (of 2,458 total)

  • RE: Inline Query

    Bill Talada (10/24/2013)


    declare @t table ( birthdate date, age as datediff(year,birthdate,getdate()) ) ;

    insert into @t (birthdate) values ('20000101')

    select * from @t

    I think this will do the trick to get someone's...

    "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 to process package even one task failed but allow other tasks to process

    All you need to do is change precedence constraint from Success to Completion.

    "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: search text within for string

    I wanted to include the XML technique for this because Text1,2 & 3 all look like truncated XML (are those the actual values or did you truncate the values for...

    "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: spliting nested string

    Ok, I know this thread is old but if PatternSplitCM[/url] was available when this was posted you could do this:

    DECLARE @string varchar(100)='1:1,3,5,7,4:56,43,58,5:34,67r,234';

    WITH prep1 AS

    (

    SELECT x.ItemNumber,

    ROW_NUMBER() OVER...

    "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 Table

    From your example code it's hard to determine what you are changing the table names to. Below is a script that works without any cursors or loops to rename tables...

    "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: Extracting Numbers from String

    I misunderstood the OP and updated my function to do what I think you are trying to do (it was originally searching for an id instead of six consecutive integers....

    "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: Extracting Numbers from String

    Edit: misinderstood the requirement. Updated my function accordingly...

    With the DelimitedSplit8K[/url] splitter function you could create an inline Table Valued function like this:

    CREATE FUNCTION dbo.string_to_table(@string varchar(8000))

    RETURNS TABLE

    AS

    RETURN

    (

    SELECTLEFT(item, CHARINDEX('...

    "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: Alternative to replace the cursor

    There are a number of ways to do this without a cursor. Here's a great article:

    Concatenating Row Values in Transact-SQL[/url]

    You could use the FOR XML PATH method and rewrite...

    "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 to delete all rows if one row meets a criteria

    mittensonmaui (10/22/2013)


    Hi all I am running a query where I check medical orders on an encounter there can be 1000's of orders and if one of them matches a specific...

    "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 order of rows will be changed when its selected?

    Just to add to what Koen said...

    The only way to guarantee that rows are returned in a specific order is when ORDER BY is used.

    It's also worth noting...

    "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 to execute stored proc iin a loop for a date range

    sqlblue (10/17/2013)


    What is the best way for me to call this

    stored proc in batches?

    Below is an example of what I think you are trying to do. This proc will keep...

    "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: XML hierarchical data

    Because you are dealing with a one-to-many parent/child node relationship you could start your query with /Root/device/sensor as your context like so:

    (Taking the example code that Mark was nice enough...

    "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: Function vs Direct query

    Though impossible to demonstrate without any DDL for the underlying tables it certainly does look like you can convert your function into a Inline Table Valued function (as has been...

    "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: join/merge 2 status tables (check statuses at any change)

    tomek tomek (10/16/2013)


    Well....

    I kind of have a solution, but it's messy (especially that I acutally have more tables like these to merge, and obviuosly there come joins with other tables).

    Maybe...

    "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: Problem with grouping in SSRS 2008

    joe.wolfe (10/11/2013)


    Yes, exactly....Thank you also for taking the time to respond and help...Joe Wolfe

    Sorry for the late reply, I've been traveling and super-busy but have been meaning to get back...

    "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 - 2,071 through 2,085 (of 2,458 total)