Forum Replies Created

Viewing 15 posts - 1,336 through 1,350 (of 6,036 total)

  • RE: SET NOCOUNT ON isn't working

    Run this query:

    SELECT * from syscomments

    where text like '%NOCOUNT OFF%'

    Some people have a habit to add SET NOCOUNT OFF to the code of their procedures.

  • RE: Merge statement with conditions

    Phil Parkin (6/28/2016)


    I still prefer the EXCEPT or INTERSECT versions, because of their inherent handling of NULLs & agree that the EXCEPT form is possibly more pleasing on the brain...

  • RE: problem converting date on procedure.

    Your problem is here:

    ' where RequestDate >= ''' + CAST(@RequestDate as nvarchar(23)) + ''''

    1. Never use CAST is SQL, especially for date-time related data types.

    The output of CAST depends...

  • RE: query performance tuning

    I've got a question about this piece of code:

    AND [Date Time Beginning (est)] >= @startdate

    AND [Date Time Beginning (est)] <= @enddate

    AND datepart(hour, br.[Date Time Beginning (EST)]) >= @starthour...

  • RE: Generate n random int subsets

    Here is the code I used:

    CREATE FUNCTION dbo.TallyN (

    @EndNumber bigint

    )

    RETURNS TABLE

    AS RETURN

    (-- Inline Tally table producing a number sequence from 1 to @SAMPLE_SIZE

    WITH T(N)...

  • RE: Generate n random int subsets

    Xedni (6/27/2016)


    Gotcha. Unfortunately, that function doesn't have the same signature as the one in your original code sample. I modified the function to accept all three parameters (start, end and...

  • RE: Dynamic Table Creation

    Don't create the table dynamically.

    Create a table once, make it have all the columns ever used in all the integrations where it's used.

    Make non-mandatory columns nullable.

    Then drop the part of...

  • RE: Generate n random int subsets

    That's how you do it:

    CREATE FUNCTION dbo.TallyGenerator (

    @EndNumber bigint

    )

    RETURNS TABLE

    AS RETURN

    (-- Inline Tally table producing a number sequence from 1 to @EndNumber

    WITH T(N) AS...

  • RE: Generate n random int subsets

    Xedni (6/27/2016)


    Could you provide the code for TallyGenerator? Since I'm not actually trying to just generate random numbers, it's difficult to see where I'd slot in my legitimate symbols, or...

  • RE: Generate n random int subsets

    This would be much shorter version:

    SELECT n.N ID, STUFF(

    (SELECT ',' + CONVERT(VARCHAR(20), n3.RandomN)

    FROM

    --picking a random quantity of random numbers per ID

    (SELECT TOP 1 N topn FROM dbo.TallyGenerator(1,3,1) WHERE...

  • RE: Merge statement with conditions

    But what if we need to identify possibly new records added to the set?

    Then we need to use a bit different form of the queries:

    SET STATISTICS IO, TIME, PROFILE ON...

  • RE: Merge statement with conditions

    Phil Parkin (6/24/2016)


    Paul White suggests that the NOT EXISTS ... INTERSECT form produces better query plans than the EXCEPT form, and that's why I use it. See here (in the...

  • RE: Merge statement with conditions

    Why do you need MERGE?

    update T

    set Event_Name = S.Event_Name ,

    Client_Name = S.Client_Name,

    [EVENT] = S.[EVENT],

    Client_Name = S.Client_Name,

    Servicer_Code = S.Servicer_Code,

    Servicer_Name = S.Servicer_Name

    FROM MasterTable T

    INNER JOIN @tempTable S...

  • RE: Return XML from SQL Server with particular format

    maruthipuligandla (6/23/2016)


    Hi,

    How can i get null row values in the below format? When i tried, I'm not getting the NULL value rows in the XML, they are being sipped.. I...

  • RE: TSQL dilemma

    Or:

    use master

    go

    DECLARE @filevalue varchar(50), @VarFileName varchar(50);

    exec testdb2.dbo.Get_Current_filename @filevalue OUTPUT

    select @VarFileName = selected_file from testdb2.dbo.FinalResult;

    select @VarFileName...result is valid

Viewing 15 posts - 1,336 through 1,350 (of 6,036 total)