Forum Replies Created

Viewing 15 posts - 31 through 45 (of 1,473 total)

  • RE: how do in insert into table after splitting using tally?

    There's always the KISS method depending on what you need this for.

    DECLARE @col2 varchar(MAX),

    @sql varchar(MAX)

    SELECT @sql = ''

    select @Col2='|AuthoriaUsers|244375064|17875716|1.14||0000037249||0000037249||||DM4||||||||||||||||||||0000037249|||||||||||||||||||||||en_US|en_US|CAD|T1_US|'

    SELECT @Col2 = STUFF(REPLACE(@Col2,'|',''','''),1,2,'')

    SELECT @Col2 = LEFT(@Col2,LEN(@Col2)-2)

    SELECT @sql = 'insert...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Trouble Declaring a Variable in a Stored Procedure

    GilaMonster (5/13/2011)


    Garadin (5/13/2011)


    Thanks for noting that Gail. I knew you needed to add a RECOMPILE but was incorrect in thinking that WITH RECOMPILE (which I've been using) worked the...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Trouble Declaring a Variable in a Stored Procedure

    GilaMonster (5/12/2011)


    Garadin (5/12/2011)


    Errr.....

    http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/

    The original code had the same problem.

    Thanks for noting that Gail. I knew you needed to add a RECOMPILE but was incorrect in thinking that WITH RECOMPILE...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Trouble Declaring a Variable in a Stored Procedure

    You've got a few options here.

    When you execute dynamic SQL, it runs in a separate context from your SP, so the fact that you declared your variables at the top...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Convert Military date to standard

    ramadesai108 (4/20/2011)


    I tried different formats on that site, but it does not work.

    Care to elaborate on that at all?

    Did your server just say "No."?

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Limiting a stored procedure

    Yeah, my bad on that one, read this too fast and missed the way the exists referred to the derived table. They can be removed from the base level...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Passing table variable or temp table as input parameter

    Alternatively, you can use XML and parse that into a temp table.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Limiting a stored procedure

    Should be as simple as removing the columns you don't want. Or am I missing something?

    It might have seemed more difficult because all kinds of shortcuts are...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: 2000 Query Analyzer - Link to 2005 Server

    At least in SQL2000, the remote table gets pulled over the network entirely and the local 2000 system will then discard the non matching rows.

    AFAIK, 2005 and 2008 behave the...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Divide by 0 Error

    Replace

    SUM(trxquantity) / SUM(trxcount) AS [UPT]

    WITH

    CASE WHEN SUM(trxcount) > 0 THEN SUM(trxquantity) / SUM(trxcount) ELSE 0 END AS [UPT]

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Need SQL Script

    I think your '-' got replaced with a double minus, probably office autoformatting. Try replacing it in your script.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: most recent row using 2 dates

    How about something like:

    SELECT Top 1 OrderNumber

    FROM Orders

    ORDER BY CASE WHEN UpdateDate IS NULL THEN CreateDate ELSE UpdateDate END DESC

    or

    SELECT Top 1 OrderNumber

    FROM Orders

    ORDER BY ISNULL(UpdateDate, CreateDate) DESC

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Compare the same field from 2 records in one table!

    deepakagarwalathome (4/1/2011)


    P.S.

    I don't have any Create table statement - the TempTest table is just coming from an existing table as a subset. The sample data set is here if...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Display 2 rows as 1 result in a column

    Check out the link to "String Concatenation" in my signature. It details quite a few different methods of doing this.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Trigger - for specific inserts only.

    repent_kog_is_near (4/1/2011)


    Seth, there are very few times that column will be populated and hence the trigger will be needed.. and hence for performance sake, i was seeking better option...

    You didn't...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

Viewing 15 posts - 31 through 45 (of 1,473 total)