Forum Replies Created

Viewing 15 posts - 31 through 45 (of 114 total)

  • RE: How to get prev and next record from a selection

    Remember, your CTE is going to go through the entire table to get the row numbers and then again to get them for the previous ID and then again to...

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: How to get prev and next record from a selection

    my query would just show you the next closest value, so you should be all set.

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: How to get prev and next record from a selection

    I'm not sure I follow what you are trying to achieve, but this might be what you are looking for, however it will likely be expensive to run:

    select id, sub,...

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: Select query to retrieve data based on current date and time

    There are likely other ways to achieve this, but you can do the following:

    Select * from TableName T

    where T.Date = Convert(date,getdate())

    and T.Time = CONVERT(time,getdate())

    You get records where the date and...

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: Profiler Event: SP:StmtStarting with TextData but empty ObjectName

    it does mean dynamic SQL. It can be in a stored procedure or the client, but since you searched the database I would say it is definitely the client.

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: Profiler Event: SP:StmtStarting with TextData but empty ObjectName

    you should have an RPC:Completed event (assuming you are tracing it) after your event in question with the same SPID. That is the calling procedure.

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: If else statement having errors

    i defer and agree with gsquared.

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: If else statement having errors

    You will need to pass the output to a table variable. Otherwise the procedure is going to return the contents of the Output operation.

    then you can do something like:

    if...

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: If else statement having errors

    you need to do the following structure:

    DECLARE @TableVariable Table

    INSERT INTO

    (Field list)

    OUTPUT INTO @TableVariable...

    SELECT Statement

    Then you have the @TableVariable that would contain what you inserted.

    Lookup INSERT and OUTPUT in Books...

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: If else statement having errors

    couple of items:

    1) The insert statement is incomplete....what are you trying to insert?

    2) What is IF output inserted.ITEMNMBR ='NULL' ??

    3) Is the field ITEMNMBR a null or...

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: Reindexing Necessity

    Excellent idea....and safer. 🙂

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: Reindexing Necessity

    be careful how you remove your PK. If you script it with a drop, dropping a clustered index will delete the table.

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: SQL Agent Agent

    what are the steps of the job? Can you post the SQL being executed?

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: Task Manager 'I/0 Write Bytes' for sqlserver.exe

    Task Manager's I/O number could be misleading without knowing how long the server has been running. What are the specs of SQL Server? Min/Max memory settings. What...

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

  • RE: select a distinct items all order by datetime

    my original SQL should work for you then.

    select Investigation_Id, Case_Id, Investigation_Note, Max(DateTime) MaxDate, Team_Id, Status_Id

    from tablename

    group by Investigation_Id, Case_Id, Investigation_Note, Team_Id, Status_Id

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

Viewing 15 posts - 31 through 45 (of 114 total)