Forum Replies Created

Viewing 15 posts - 121 through 135 (of 283 total)

  • RE: adp,parameters in functions, subsequent views

    Yes, you can add role-based intelligence inside the function, or you could have different functions and control access to them through roles. Personally, I prefer the latter method as I...

  • RE: A View Or a Stored Procedure?

    yuryn1961 (4/21/2008)


    SELECT COALESCE(NULLIF(CUST_NAME_RU, ''), CUST_NAME_EN) AS CUST_NAME

    FROM [CUSTOMERS]

    Why use Coalesce and IsNull (I assume that's what NULLIF really is)? Actually, the code above is not going to give you what...

  • RE: adp,parameters in functions, subsequent views

    I don't know why you just couldn't use:

    select * from dbo.function1( '2007-12-01', '2007-12-31' )

    instead of wrapping the function (itself a wrapper) inside a view.

    Your problem is that there is no...

  • RE: Static Parameters

    No problem. To set to beginning of the current month:

    set @BeginDate = DateAdd( mm, DateDiff( mm, 0, GetDate()), 0 );

    To set to beginning of the current year:

    set @BeginDate = DateAdd(...

  • RE: How to insert more rows into sql server table using stored procedure?

    -- For 2005 and later

    Create Procedure InsertRows

    @NumberOfRows tinyint

    as begin

    INSERT INTO User_Group_Map

    ...

  • RE: Static Parameters

    Do you mean something like this:

    Create PROCEDURE [dbo].[usp_ReportGlassStatsWeb]

    @StartDate datetime = null, -- Allow a null value

    ...

  • RE: Creating & Executing a Funtion

    If I may put in my 2 cents.

    ALTER FUNCTION [dbo].[PostArea](

    @lcPostcode VARCHAR(4))

    RETURNS VARCHAR(2)

    Are you certain that a function that strips digits from a string will only ever...

  • RE: COUNT (Distinct Column) = 0 with GROUP BY

    You have to force a null value for empty days, that's what a Tally or Numbers table does well. Then just some GROUP BYs and you don't need a DISTINCT,...

  • RE: Inserting a Row into a recordset

    Yes. But in reading your original post, I thought that's what you wanted when you said, "regardless if they have data for them."

  • RE: Keeping a distinct list of inserted values ....

    Oops. One of those oversights that could go a really long time before manifesting itself. :blush:

    However, I still like the join better. It's simple and easy to maintain -- and...

  • RE: Replace non numeric characters in string

    For what it's worth, here's my entry:

    create function ExtractDigits (

    @Pattern varchar( 8000 )

    )

    RETURNS varchar( 8000 )

    as begin

    declare @Result varchar( 8000 );

    select @Result = '';

    select @Result...

  • RE: Inserting a Row into a recordset

    Am I missing something or are you guys making this much more difficult than it should be? In general, you can do this:

    select <column list>

    from whatever-to-get-original-resultset

    union

    select <column...

  • RE: SELECT COUNT(*)

    Here is a function we wrote based on info posted here and elsewhere:

    /*

    This function will return the number of rows in a table, the same result

    as executing a "Select Count(*)...

  • RE: Finding DML action that fired trigger

    Both pseudo tables exist for every trigger. Here is a code snippet I include in every multiple-operation trigger:

    if @@RowCount = 0

    ...

  • RE: Keeping a distinct list of inserted values ....

    Having this in the insert trigger shouldn't be too bad.

    Create trigger trg_Name

    on Customers after insert as

    ...

    insert into DistinctTable(Name)

    select i.Name

    from inserted i

    left join...

Viewing 15 posts - 121 through 135 (of 283 total)