Forum Replies Created

Viewing 15 posts - 541 through 555 (of 2,007 total)

  • RE: read the current row and previous row & calculate difference reporting values over

    CELKO (8/15/2012)


    Now we have to fix the bad schema with DML. Look up the new CREATE SEQUENCE statement and use it. Here is an untested attempt:

    WITH Corrected_Tests (device_id, test_value, device_test_seq)

    AS

    (SELECT...

  • RE: How to escape the ^ symbol in the following function

    Abu Dina (8/15/2012)


    Cadavre, the ^ at the end is there to exclude the - from being removed.

    Adi, I'm happy with your solution!

    Thanks to you both.

    Test mine 😉

    Your code: -

    IF EXISTS...

  • RE: How to escape the ^ symbol in the following function

    Total guess, no testing has gone into this: -

    CREATE FUNCTION [dbo].[fn_QBRemoveNonAlphaChars] (@String VARCHAR(1000))

    RETURNS VARCHAR(1000)

    AS

    BEGIN

    WHILE PATINDEX('%[^a-z ''-]%', @String) > 0

    SET @String = STUFF(@String, PATINDEX('%[^a-z ''-]%', @String), 1, '')

    RETURN @String

    END

    You had the...

  • RE: read the current row and previous row & calculate difference reporting values over

    scott_lotus (8/15/2012)


    Edit to say, not sure is UNION is a good idea, find it very slow on + billions records.

    The UNIONs that some have posted are part of creating sample...

  • RE: read the current row and previous row & calculate difference reporting values over

    Luis Cazares (8/15/2012)


    DECLARE @Tabletable(

    idint,

    device int,

    value int)

    INSERT @Table

    SELECT 9, 456, 70 UNION ALL

    SELECT 8, 456, 60 UNION ALL

    SELECT 7, 123, 70 UNION ALL

    SELECT 6, 123, 60 UNION ALL

    SELECT 5, 456, 50...

  • RE: read the current row and previous row & calculate difference reporting values over

    scott_lotus (8/15/2012)


    I am trying to write a script to read the current row and previous row per device and work out the difference reporting values over X (> than 20...

  • RE: Format number thousands separator with point

    Luis Cazares (8/14/2012)


    Wouldn't this be defined by the regional settings? If the settings affect the format for money, this can result problematic.

    I don't believe so. Normally I'd just test it,...

  • RE: Can you execute a VB.NET .exe from within SQL?

    N11689 (8/14/2012)


    We need to execute a VB.NET (2010) executable from SQL (2005).

    Is this possible, and what is the best way to do this?

    I guess this might work: -

    EXEC master..xp_CMDShell 'c:yourFile.exe'

  • RE: remove last line

    Out of curiosity, does this correct your issue?

    DECLARE @str NVARCHAR(MAX);

    SELECT @str = STUFF((SELECT CHAR(13) + CHAR(10) + csvFile

    ...

  • RE: Format number thousands separator with point

    cms9651 (8/14/2012)


    Format number thousands separator with point

    Hi there, I need your help.

    I have this number in my database output result of query:

    1013473

    I need this output: 1.013.473

    Can you help me?

    Thanks...

  • RE: Intresting Query

    Eugene Elutin (8/10/2012)


    And, sorry, for typing in capital, I didn't intend to shout, I just wanted to make the sentence appear bold, as it's quite important tip.

    Apology accepted, I...

  • RE: Intresting Query

    Eugene Elutin (8/10/2012)


    4. Do not create new SqlString, just cast the result of regex.replace

    That's redundant.

    using System;

    using System.Data.SqlTypes;

    using System.Text.RegularExpressions;

    namespace TrimTrailingLeading

    {

    public class UserDefinedFunctions

    {

    ...

  • RE: Intresting Query

    Eugene Elutin (8/10/2012)


    try to return

    (SqlString) s.Value.TrimStart('0').TrimEnd('0');

    instead of

    new SqlString(s.Value.TrimStart('0').TrimEnd('0'));

    what about Regex?

    Don't forget to create static Regex object instead of instance in the function.

    To remove leading...

  • RE: Intresting Query

    CLR Version 1:

    using System;

    using System.Data.SqlTypes;

    namespace TrimTrailingLeading

    {

    public class UserDefinedFunctions

    {

    [Microsoft.SqlServer.Server.SqlFunction]

    ...

  • RE: Intresting Query

    dwain.c (8/10/2012)


    I'm thinking the winner has more to do with the number of zeroes replaced because I got quite a variation on results for this.

    For overall terseness, I kinda like...

Viewing 15 posts - 541 through 555 (of 2,007 total)