Forum Replies Created

Viewing 15 posts - 7,621 through 7,635 (of 8,731 total)

  • RE: splitting a string into columns

    I hope that you're trying to eliminate this horrible design to have a properly normalized table.

    You can accomplish using the 8KDelimitedSplitter[/url] and CROSS TABS[/url]

    SELECT MAX( CASE WHEN LEFT( Item, 1)...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: trying to create a table - unpivot

    Here's something for you to start with. To understand this method called CROSS TABS, you could visit this article: http://www.sqlservercentral.com/articles/T-SQL/63681/

    To learn how to make it dynamic, use part 2: http://www.sqlservercentral.com/articles/Crosstab/65048/

    WITH...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Filter Countries, States and Cities which in same row in one table.

    What about normalizing data?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: split performance

    sathiyan00 (10/8/2013)


    but even this is also taking more time for 25K records.

    with Improved SQL 8K “CSV Splitter” Function its taking around 25 sec

    with xml its taking around 30sec

    with substring its...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: lookup table for minutes of a day

    If you wan't for display, you can convert to string using convert.

    To remove seconds from the datetime, you can do something different.

    Either you specify the exact time to start or...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Split character sting - Selected Part

    Use it as any other TVF

    DECLARE @String varchar(100)='123,0.934,98,928.34,987.45'

    SELECT *

    FROM dbo.DelimitedSplit8K(@String, ',')

    WHERE ItemNumber IN(3,5)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: lookup table for minutes of a day

    Using a Tally Table (or in this case a CTE) it's really easy to do it.

    Here's an example:

    WITH e1(n) AS(

    SELECT * FROM (VALUES(1),(1),(1),(1),(1),(1),(1),(1),(1),(1))x(n)

    ),

    e2(n) AS(

    SELECT e1.n FROM e1, e1 x

    ),

    e4(n) AS(

    SELECT...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Building a Comma Separated on a new line

    Where are you checking the results? The grid from SSMS won't show line feeds.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Rounding issue

    From some point of view, 0.1538461 is almost equal to 15.385%

    What's your question? What do you need? Couldn't you do it on the front-end?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Return only values that are all numeric from a varchar

    Using SQL Server 2012, you could use TRY_CONVERT or TRY_CAST which will return a NULL value when a conversion can't be made.

    Another option is described on the following article

    http://www.sqlservercentral.com/Forums/Topic1028368-203-1.aspx

    Here's...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: SQL Select Case

    And that's why you should post DDL with your questions. And as this is a SQL Server site, you should tell us that you're not using SQL Server :-D.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Replacing NULL with 0 when using the Pivot operator

    Maybe you could try a CROSS-TABS approach.

    SELECT location_name,

    MAX( CASE WHEN month = '2008-03' THEN total_offices ELSE 0 END) [2008-03],

    MAX( CASE WHEN month = '2008-04' THEN total_offices ELSE 0 END) [2008-04]

    FROM...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Looking for a faster count than count(*) for my sp.

    Here are some suggestions that might be wrong but I can't test performance without actual knowledge of your environment:

    - Instead of using a CTE, use a temp table to insert...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: JOIN issue

    You might want to add a column to your queries, using ROW_NUMBER().

    Here's an example, but without some data more similar to the real data, it's hard to give a good...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: JOIN issue

    SrcName (10/4/2013)


    if the logic is like this then you may use RIGHT (not in where becouse there is performance problem)

    you can try on this way:

    select * from TABLE1 t join

    (...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 7,621 through 7,635 (of 8,731 total)