Forum Replies Created

Viewing 15 posts - 16 through 30 (of 901 total)

  • RE: TRY/CATCH blocks in SQL

    You cant use a Create <object> inside a try catch scenario as the CREATE needs to be the first statement.

    That's why you use the If Exists.

    If you want...

  • RE: Performance Risk\Impact of Partitioning

    To My knowledge TEXT data fields havent been fully depreciated and there are ways round it with Custom Datatypes when it does happen, but thought Id make you aware. ...

  • RE: Move sleeping spid to running or RUNNABLE

    To my knowledge there is no way to do this as there are simply connections that are open but not in use.

  • RE: Performance Risk\Impact of Partitioning

    Hi,

    hope you dont mind me asking is this for an insurance company or a building maintenance company?

    Just had a look at tblcall and that needs a bit of work,...

  • RE: Performance Risk\Impact of Partitioning

    Sergiy,

    There is always the 'It depends' caveat when looking at the this type of thing, and in a lot of cases the actual table design is the issue, especially if...

  • RE: Where clause prevents index seek

    I suspect that the engine is reverting to a cached plan, and reading BoL in regards to the RECOMPILE query hint

    Instructs the SQL Server Database Engine to discard the...

  • RE: Need comma separated output

    what have you tried?

  • RE: UPDATE statement help

    Thanks drew, I've just tried with First_value and an ORDER BY AsOFDate DESC) and that works perfectly.

  • RE: How to get 'Year' in a case statement

    could be a couple of things, but firstly YEAR(hr.dob) will return an integer so you need to convert it to a VARCHAR so try

    CONVERT(VARCHAR(10),year(hr.dob))

    That should help fix it.

  • RE: Insert into select from - View

    Minnu (11/19/2015)


    CREATE VIEW [dbo].[test_view]

    AS

    SELECT DISTINCT p_id, p_name

    FROM unify

    ERROR : Incorrect syntax near the keyword 'INSERT'.

    Please help

    You cant use an the INSERT in a view.

    You could do

    CREATE VIEW [dbo].[test_view]...

  • RE: UPDATE statement help

    serg-52 (11/19/2015)


    Jason-299789 (11/19/2015)


    The LAST_VALUE function will probably work, but will need an sort on the columns

    SELECT

    tgt.*

    ,LAST_VALUE(Class4) OVER (PARTITION BY identifier ORDER BY identifier)

    FROM #TestTable tgt

    Order by...

  • RE: UPDATE statement help

    Jeff,

    Thank you for the feedback on the TOP 100 Percent, I do try and avoid it whenever possible, but I know ORDER BY is not allowed in CTE's without a...

  • RE: UPDATE statement help

    Jeff,

    I dont think Lead/Lag will help in this case as it will only update by a given offset, so using the example

    SELECT

    #TestTable.*

    ,LEAD(class4,1,class4) OVER (PARTITION BY identifier ORDER BY...

  • RE: Get previous row's value - with a twist!

    Sorry to say your script wont run for the following reasons

    1) the insert into #mytable doesnt match the definition of the temp table

    2) the select statement has 3 columns...

  • RE: Good Basic T-SQL Exercises

    Heres a good real life example I came across.

    This takes annual Yield curves and then calculates a Cumulative End of Month position.

    The data values provided are at End...

Viewing 15 posts - 16 through 30 (of 901 total)