Forum Replies Created

Viewing 15 posts - 6,691 through 6,705 (of 8,731 total)

  • RE: Insert Blank row between result

    It can be done in SQL, but if you're using a reporting tool, you should do it in there.

  • RE: How to get the date?

    Assuming you have @@DATEFIRST = 7, you could use this formula:

    SELECT CASE WHEN DATEPART(DW, DATEADD( MM, DATEDIFF(MM, 0, GETDATE()), 0)) = 2

    THEN DATEADD( DD, 4, DATEADD( MM, DATEDIFF(MM, 0, GETDATE()),...

  • RE: Removing 2000 Compatibility Mode - New Problem

    The reason that makes the query work without the alias is that a.JOB_Date is different to JOB_Date which is the column alias.

    I'm not sure how would you be able to...

  • RE: Finding the longest string within a string field

    And after some testing on SQL Server 2012, the DelimitedSplit8K still is the fastest solution posted in this thread. However, I haven't tested the new version presented by Eirikur in...

  • RE: select with single quotes

    You can concatenate the quotes

    SELECT '''' + Column1 + '''' AS quotedColumn1

    FROM TableA

  • RE: Pivot Table

    Why are you using 100, 101 & 102 for statos when you don't seem to have that values in your stato column?

  • RE: Exporting to CSV

    Informer30 (3/24/2014)


    ok - I am understanding correctly -

    1. output to csv or txt

    2. then in excel import the csv or txt and I should see all of the 2million...

  • RE: Finding the longest string within a string field

    thava (3/24/2014)


    how about a recursive idea

    It's nice, but the DelimitedSplit8K version will work in half the time :-). You might not notice it with a few rows but it becomes...

  • RE: LEFT JOIN not returning anticipated results from Left table in query

    Would this give you the correct result?

    SELECT

    Users.Department as Dept,

    CaseTypes.Description as Case_Type,

    Users.Code as FE,

    COUNT(Matters.FeeEarnerRef) as No_of_Matters,

    ISNULL(SUM(Usr_Int1.Estimated_total_fee),0) as Fee_Estimate

    FROM

    ((Users LEFT JOIN Matters ON Users.Code = Matters.FeeEarnerRef and...

  • RE: Help me optimise this query

    You need to provide more information. To find out what could be wrong, people need DDL for tables and indexes, as well as actual execution plan as described in this...

  • RE: Find null values between 3 datasets, in one table

    Using CROSS TABS you could achieve this easily without UNION ALL.

    SELECT MAX( CASE WHEN system = 'system 1' THEN item END) system1

    ,MAX( CASE WHEN system = 'system 2' THEN item...

  • RE: convert binary string to table value construct

    Here's another option. I was thinking more of creating it for an iTVF (but leaving that part to you).

    DECLARE @String varchar(20) = '00001001001';

    WITH e1(N) AS(

    SELECT N FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))e(N)

    ),

    cteTally(N) AS(

    SELECT TOP(LEN(@String))...

  • RE: Table scan in Query Tuning

    It depends, I would add a clustered index before thinking about a non-clustered one. It depends as well on the size of the table and the columns and rows used...

  • RE: Rows to Columns on for Date Datatype

    Why do you say you can't use aggregate functions on dates? SUM isn't the only aggregate available.

    Is this what you need?

    Select @SQL2 = ISNULL(@SQL2+',','') + CHAR(13)

    ...

  • RE: Ambiguous column name

    That has always been like that. It's not new to 2008, it already existed on 2000. The query might have been changed.

Viewing 15 posts - 6,691 through 6,705 (of 8,731 total)