Forum Replies Created

Viewing 15 posts - 7,426 through 7,440 (of 8,731 total)

  • RE: Change format Numeric to mmm-yy

    As CONVERT won't give you the format you require, you need to play with the string returned.

    SELECT REPLACE( RIGHT( CONVERT( varchar(9), GETDATE(), 6), 6), ' ', '-'),

    STUFF(...

  • RE: SQL works fine, but doe's not work called by a Stored Procedure

    Why are you inserting into a table variable and then selecting from it instead of doing the select directly as you do with your original query?

    Sean, I can't see why...

  • RE: calendar from table

    As it might get complicated for someone who is not related to all of the techniques mentioned, here's an example using a CTE for the sample data.

    Check it and ask...

  • RE: calendar from table

    Besides of the CROSS TABS, you should review the concept of a Tally Table and I believe you might want to check on creating character-separated lists to have just one...

  • RE: Which way is better in SQL Paging (With or TempTableVariable) & Why ??

    I would go for the CTE option since it doesn't require to copy the whole table just to filter the results instead of doing it in the same statement.

  • RE: Update field based on condition

    This is basically the same that the previous update posted by Abu Dina.

    UPDATE o SET

    orderStatus = CASE WHEN s.orderQty = s.receivedQty THEN 'Complete'

    WHEN s.orderQty > s.receivedQty AND s.receivedQty > 0...

  • RE: Data type validations

    Beware of ISNUMERIC(), you might have some problems if you don't consider all the possibilities.

    http://www.sqlservercentral.com/articles/IsNumeric/71512/

    If you're using SQL Server 2012 or 2014, go for TRY_PARSE,TRY_CONVERT or TRY_CAST.

  • RE: What is SQL Server not good at?

    Even if it's included in BOL, would people read the warnings?

    Most people having bad coding habits won't even read basic documentation and go for what they suppose is better with...

  • RE: Pivot All Columns

    You're right Scott. I'm not sure why did I have that in mind.

    Silly me.:hehe:

  • RE: Data type validations

    As Sean pointed out, this is a really bad idea. However, if you need help, please post DDL, sample data in the form of INSERT statements, expected results and what...

  • RE: Pivot All Columns

    Unfortunately, with approximate numerics you don't have many options. And here they are:

    DECLARE @n float = -1.19056542300058E+15

    SELECT @n float,

    CONVERT( varchar(13), @n, 0 ) with_6_digits,

    CONVERT( varchar(15), @n, 1 )...

  • RE: Is this a safe way of truncating the log inmediately in full recovery model

    If it will grow everyday anyway, why would you want to shrink it? Do you dislike good performance?

    As I understand, your log backup is not there for disaster recovery but...

  • RE: Query assistance please: fetching repeated values

    Here's an option. If your ID has gaps, you should create a virtual one using ROW_NUMBER()

    SELECT t1.*

    FROM @t t1

    LEFT

    JOIN @t t2 ON t1.ID = t2.ID + 1 AND t1.Value =...

  • RE: Pivot All Columns

    You don't have to convert all of them explicitly using CAST or CONVERT unless you need a special format.

    As all values will show in a single column, the first value...

  • RE: Pivot All Columns

    You're looking for UNPIVOT or an alternate version using CROSS APPLY and VALUES[/url].

    select x.*

    from #Member

    CROSS APPLY(VALUES('RowID', CAST( RowID AS varchar(100))),

    ('FirstName', FirstName),

    ('MiddleName', MiddleName),

    ('LastName', LastName),

    ('StreetAddress', StreetAddress),

    ('Suite', Suite),

    ('CityName', CityName),

    ('StateName', StateName),

    ('PostalCode',...

Viewing 15 posts - 7,426 through 7,440 (of 8,731 total)