Forum Replies Created

Viewing 15 posts - 811 through 825 (of 3,543 total)

  • RE: How to convert nvarchar to date data type?

    ;WITH c (current_week,fromdate,todate) AS (

    SELECT current_week,CAST(LEFT(current_week,10) as date),CAST(RIGHT(current_week,10) as date)

    FROM #mytable

    )

    SELECT DISTINCT c.current_week,n.current_week AS [next_week]

    FROM c

    JOIN c n ON DATEADD(day,-8,SYSDATETIME()) BETWEEN n.fromdate and n.todate...

  • RE: Connecting other sql server database from sql query

    Grant Fritchey (4/23/2014)


    Another way to do it is to use OPENQUERY. There are examples at the link.

    Or OPENROWSET as referenced at the bottom of the link 🙂

  • RE: SSRS 2008 R2

    1. The Report Server must be able to open a SQL Connection to the SQL Server

    (I assume this is OK as you can run the report...

  • RE: SQL/SRSS Newbie Assistance Needed :)

    richardgregory06 (4/23/2014)


    I"m still a bit confused which is typically the "Best Practice" to where I should put the criteria

    It depends!

    Check which method yields the best performance.

    p.s.

    Which is better

    asking SQL Server...

  • RE: Need a logic

    1. You have anerror in your keyword table, both 'already' and 'Deactivated' have id=1

    2. Like will not work as 'activated' keyword will find 'activated' and 'Deactivated'

    Solution using splitter

    SELECT m.[Description]

    FROM...

  • RE: Need to un-pivot some columns, pivot one column

    SELECT t.CampusID,t.Campus,t.TermID,t.Term,t.StudentID,t.Qualification,t.Programme,s.Status

    FROM [dbo].[MyTable] t

    CROSS APPLY (

    VALUES

    ('Repeat1stYear',t.Repeat1stYear)

    ,('Repeat2ndYear',t.Repeat2ndYear)

    ,('Repeat3rdYear',t.Repeat3rdYear)

    ,('ProgTo2ndYear',t.ProgTo2ndYear)

    ,('ProgTo3rdYear',t.ProgTo3rdYear)

    ,('ProgToCompleteQual',t.ProgToCompleteQual)

    ,('NotReturn2ndYr',t.NotReturn2ndYr)

    ,('NotReturn3rdYr',t.NotReturn3rdYr)

    ,('NotReturn4thYr',t.NotReturn4thYr)

    ) s (Status,StatusValue)

    WHERE s.StatusValue = 1

  • RE: Set value based on previous row

    ;WITH a (ID,ImportGroup) AS (

    SELECTc.ID,ROW_NUMBER() OVER (ORDER BY c.ID)

    FROM@data c

    LEFT JOIN @data n ON n.ID = c.ID + 1

    WHERE(c.EventTypeID IN (1,2,4) AND n.EventTypeID in (0, 3))

    OR(c.EventTypeID IN (0, 3) and...

  • RE: split big query into two different query using global temp table

    After just perusing the query I do not think you will be able to split it in two, it is too large.

    Even after replacing tab and crlf with space and...

  • RE: Not Able to Get 2 Decimal Places to Show When Decimal Place Value is 0

    miles_lesperance (4/11/2014)


    That worked!! That expression was written by a previous developer, and I was trying to modify it to get rid of the divide by zero error that would occur....

  • RE: Assigning Batchid to Cake Making Process

    sunil.mvs (4/11/2014)


    Cake can have x steps and it depends on customer request .. Once work flow starts it starts with 1 and reaches nth...

  • RE: Not Able to Get 2 Decimal Places to Show When Decimal Place Value is 0

    use this expression

    =IIF(Sum(CDec(Fields!Field2.Value))=0,0,Sum(CDec(Fields!Field1.Value))/IIF(Sum(CDec(Fields!Field2.Value))=0,1,Sum(CDec(Fields!Field2.Value))))

    and set the format to P2

    *Edited to include CDec

    You should change your code to not use strings for numeric input

  • RE: Are the posted questions getting worse?

    GilaMonster (3/24/2014)


    It's probably nothing more than a case of "Why's the <app which has been working for years> not working? What do you mean 'who's the administrator'? We've never needed...

  • RE: Reg -Joins

    If you are using ID for the join you will get a Cartesian result.

    How do you know which row in table b belongs to each row in table a?

  • RE: SQL for adding flags depending on criteria

    ;WITH cte (CustId,OrderId,OrderDate,RowNumber) AS (

    SELECT CustId,OrderId,OrderDate

    ,ROW_NUMBER() OVER (PARTITION BY CustId,YEAR(OrderDate),MONTH(OrderDate) ORDER BY YEAR(OrderDate),MONTH(OrderDate))

    FROM

    )

    SELECT CustId,OrderId,OrderDate,SIGN(RowNumber)-SIGN(RowNumber-1) AS [CountUnique]

    FROM cte

  • RE: Splitting single comma separated line

    As already stated fix the problem at source.

    Probable cause of 'joining' lines is missing CR char ie LF instead of CRLF

    If this is the case delimit on LF and remove...

Viewing 15 posts - 811 through 825 (of 3,543 total)