Forum Replies Created

Viewing 11 posts - 46 through 57 (of 57 total)

  • RE: SQL LEN Function

    Rick, it does return the space at the end:

    DECLARE @str NVARCHAR(10)

    SET @str = '1, 2, 3, '

    SET @str = LEFT(@str, LEN(@str)- 2)

    select len(@str)

    SELECT @str

    SELECT RIGHT(@str,1) -- returns space, not a...

    /* Anything is possible but is it worth it? */

  • RE: Select a column dynamically

    T4FF (7/13/2009)

    The coalesce could work, but I can't be sure as to whether the other columns will be blank. Thanks for your suggestions will try each out and see...

    /* Anything is possible but is it worth it? */

  • RE: Converting Comma Separated value into a Table

    Well, I guess I was off a bit more than I thought I was.

    DECLARE @t TABLE (col2 varchar(30));

    INSERT INTO @t

    SELECT '1,11,2,22,3,33';

    ; WITH t1 (col2) AS

    (

    ...

    /* Anything is possible but is it worth it? */

  • RE: Converting Comma Separated value into a Table

    WayneS (6/22/2009)


    Gatekeeper (6/22/2009)


    This was answered 2 days ago: http://www.sqlservercentral.com/Forums/Topic738904-338-1.aspx

    No it wasn't. Similiar, but yet completely different.

    I wouldn't say completely different. All I removed was col1 from the posted code I...

    /* Anything is possible but is it worth it? */

  • RE: Data masking - protecting confidential data

    What about creating a new user and only assigning it access to views you have written? Then in your view, you can say SELECT '123-45-6789' as SSN, 'First M. Lastname'...

    /* Anything is possible but is it worth it? */

  • RE: Converting Comma Separated value into a Table

    This was answered 2 days ago: http://www.sqlservercentral.com/Forums/Topic738904-338-1.aspx

    /* Anything is possible but is it worth it? */

  • RE: date conversion

    Allister Reid (6/9/2009)


    declare @temp as table (txtdate varchar(10))

    insert into @temp select '071009' union select '42209'

    select

    CONVERT(datetime,

    case

    when LEN(txtdate) = 6 then STUFF(STUFF(txtdate, 3, 0, '-'), 6, 0, '-')

    else...

    /* Anything is possible but is it worth it? */

  • RE: Checking Negative Number

    See the last statement to lose the case statements.

    DECLARE @Result1 INT

    DECLARE @Result2 INT

    SELECT @Result1 = MAX(p.Col1) - SUM(CASE WHEN s.Col2 > s.Col1

    THEN s.Col2 - s.Col1

    ELSE 0

    END),

    @Result2 = SUM(CASE WHEN...

    /* Anything is possible but is it worth it? */

  • RE: T-SQL to generate create table script?

    Why not setup profiler to run while you run the "Generate Script" from Studio? That should give you all the needed pieces. Then you would need to replace the "hard...

    /* Anything is possible but is it worth it? */

  • RE: Correlated Joins Using "Apply"

    We've been using the ROW_NUMBER() method for a while now and it's great for reporting purposes. Not to mention, its speed is great compared to using UDFs or inserting into...

    /* Anything is possible but is it worth it? */

  • RE: Deleting old records

    For finding the number of days in your select instead of a set value:

    DELETE FROM Table WHERE Column < (GETDATE() - DAY(DATEADD (d, 1 - DAY(GETDATE()), GETDATE()) - 1))

    /* Anything is possible but is it worth it? */

Viewing 11 posts - 46 through 57 (of 57 total)