Forum Replies Created

Viewing 15 posts - 3,976 through 3,990 (of 10,144 total)

  • RE: How to add this condition into where clause? Thanks.

    Or this?

    SELECT *

    FROM document

    WHERE (@dt = 1 AND doctype IN (1, 2))

    OR (@dt = 0 AND doctype = 1)

  • RE: Today's Random Word!

    SQLRNNR (9/12/2013)


    subjugate

    Pimms

  • RE: making records unique

    What results do you get from this query?

    ;WITH Deleter AS (

    SELECT

    ID,

    rn = ROW_NUMBER() OVER(ORDER BY Postcode,BuildingName,housenumber,SubBuilding,County,Town,

    LocalName,PostOutCode,PostInCode,Throughname,Throughdesc,poboxno,BusinessName,locality)

    FROM PostCodesAndAddressesBt

    )

    SELECT *

    FROM Deleter

    WHERE rn > 1

  • RE: making records unique

    Can you post a few rows please Mick, showing some dupes?

  • RE: making records unique

    mick burden (9/12/2013)


    Hi everyone, I've a table with 15 fields with 70,000 rows of data. I now realise I need to make each record unique.

    Easy.

    I could have gone down...

  • RE: problem with subtracting one millisecond

    phoenix_ (9/12/2013)


    ... Am I doing something wrong?..

    Possibly. If the datetime you are constructing is the upper bound of a range, you will almost certainly find it easier to use the...

  • RE: Comparing a to a substring

    The CTE is nothing more than a macro, it will be substituted into the query and result in LEFT() in the join. There's no gain.

  • RE: Select several subqueries with more than 1 value

    Your initialisation code fails with an error. Your expectations are incorrect.

    I think this is what you are looking for:

    CREATE TABLE #table1(c nvarchar(1));

    CREATE TABLE #table2(c nvarchar(1));

    INSERT INTO #table1 SELECT '1' UNION...

  • RE: Comparing a to a substring

    kapil_kk (9/11/2013)


    Amit Raut (9/11/2013)


    SELECT * FROM Table A

    INNER JOIN Table B

    WHERE LEFT(A.UserName, 7) = B.ID -- RELEVANT FIELD FROM TABLE B

    Its not a good practice to use functions like LEFT,...

  • RE: How do I convert column data into row data?

    Dwain C has a nice article covering usage, I've put a link in an earlier post in this thread.

    Blimey. I've learned so much from your website over the years. Nice...

  • RE: How do I convert column data into row data?

    Erland Sommarskog (9/11/2013)


    ChrisM@Work (9/4/2013)


    Or CROSS APPLY VALUES

    Somewhat odd to use CROSS APPLY here. The normal is CROSS JOIN. Of course since there is no correlation on the right side, the...

  • RE: Getting duplicate values evenif used distinct

    jaiswalabhishek22 (9/11/2013)


    ...Can anyone please tell me how can I get expected 1769894 count...

    Begin with the query below. Uncomment a single table source at a time, and run through all of...

  • RE: Weird Date Issue slowing down Stored Proc

    Charlottecb (9/11/2013)


    Hi ChrisM,

    Many thanks for taking the time to do this - I'll try out your version to see how much quicker it performs.:-D

    You're welcome. With no sample data to...

  • RE: Weird Date Issue slowing down Stored Proc

    Charlottecb (9/11/2013)


    Just ran EXEC sp_updatestats and the problem has gone away! 😀

    Excellent!

    You might get better performance from this query by preaggregating some of those tables feeding the three subqueries, something...

  • RE: wildcards

    batgirl (9/11/2013)


    LOL...here's my thought process.

    Quick read - looks like it should return 2 rows.

    Hmmm...are 2 rows = 2 results? Not really...it's 1 result.

    Look again...looks like Steppenwolf will...

Viewing 15 posts - 3,976 through 3,990 (of 10,144 total)