Forum Replies Created

Viewing 15 posts - 4,966 through 4,980 (of 5,393 total)

  • RE: How do I have an INT variable default to the wildcard if NULL in a Stored Procedure..?

    Short answer:

    ALTER PROCEDURE dbo.sp_Status_3

    (

    @myLocationRef int,

    @myReviewerRef int =NULL,

    @myBURef int =NULL

    )

    AS

    SELECT *

    FROM dbo.tmp_sp_Status_2

    WHERE (ReviewerRef = COALESCE(@myReviewerRef,ReviewerRef)) AND (BURef = COALESCE(@myBURef, BURef)) AND (LocationRef = @myLocationRef)

    Long answer:

    This code works, but it is not...

    -- Gianluca Sartori

  • RE: How do i know which process using my particular table ?

    Try this:

    select *

    from sys.dm_tran_locks

    where resource_database_id = db_id()

    and resource_type = 'OBJECT'

    and resource_associated_entity_id = object_id('MyTable')

    -- Gianluca Sartori

  • RE: append code to the duplicate name

    Try this:

    select e.ecode, ename = e.ename + CASE WHEN counts.cnt > 1 THEN ' ' + e.ecode ELSE '' END

    from emp as e

    inner join (

    select ename, count(*) as cnt

    from emp

    group...

    -- Gianluca Sartori

  • RE: Are the posted questions getting worse?

    I don't think this is a good behaviour.

    I go through all new posts every day and I start from unanswered questions. If I...

    -- Gianluca Sartori

  • RE: Using CURSOR

    Hi Jeff, thanks for chiming in!

    When will the article be online again? It's hard to explain this technique to others without the help of your article... expecially for poor pretenders...

    -- Gianluca Sartori

  • RE: Using CURSOR

    You could use the famous "quirky update" algorithm by Jeff Moden.

    It is described in an article that is currently under construction. I hope it will be soon fixed. The link...

    -- Gianluca Sartori

  • RE: Are the posted questions getting worse?

    Bob Hovious (8/4/2009)


    I don't think he was comparing apples to apples.

    No, he got confused by sp_spaceUsed.

    It really is interesting anyway.

    Saving XML in tables and treating it as if it...

    -- Gianluca Sartori

  • RE: Using CURSOR

    I also suggest not to use cursors: they're slow.

    There's almost nothing that can't be done without cursors.

    -- Gianluca Sartori

  • RE: Using CURSOR

    SET @RESULT= @RESULT + @RECEIVE - @PAY

    -- Gianluca Sartori

  • RE: Sql execption

    You could add a parameter to uspGetError to pass the procedure name (OBJECT_NAME(@@procid)).

    -- Gianluca Sartori

  • RE: Edit DTS package in structured file

    You have to open the DTS package from the Enterprise Manager.

    Right click Data Transformation Services and choose "Open Package". Pick the file from the dialog and choose open.

    You can now...

    -- Gianluca Sartori

  • RE: Filtering by date

    Hi, it's not clear to me what you are trying to achieve.

    I'm posting the sample data so other users can test solutions.

    DECLARE @table TABLE (

    item int,

    Sales_date datetime,

    Quantity int,...

    -- Gianluca Sartori

  • RE: Gain Space Using XML data type

    Nice article, I learned something about XML in SQL Server today.

    As Paul pointed out, it's impossible that XML storage needs less space than conventional storage.

    With appropriate indexing, there's no way...

    -- Gianluca Sartori

  • RE: Table Modification Auditing

    You could also get the full SQL command that fired the trigger:

    SELECT text

    FROM sys.dm_exec_requests

    CROSS APPLY sys.fn_get_sql(sql_handle)

    But I don't know if this fits your needs.

    -- Gianluca Sartori

  • RE: Table Modification Auditing

    I guess the problem is trigger_events: it contains every event that makes the trigger fire, not the event that fired the trigger NOW.

    You could guess the operation type looking at...

    -- Gianluca Sartori

Viewing 15 posts - 4,966 through 4,980 (of 5,393 total)