Forum Replies Created

Viewing 15 posts - 301 through 315 (of 423 total)

  • RE: Subtracting specific dates from today

    That's good to know. But my point was concerning the ISDATE function. As these examples point out, no matter how sound the logic may be for a CAST (or CONVERT)...

  • RE: Subtracting specific dates from today

    ISDATE isn't quite in sync with all of the date datatypes. I just think it's prudent to prevent an unexpected failure of a procedure to check an alleged "date" by...

  • RE: Subtracting specific dates from today

    To prevent unexpected errors, you should validate your dates. And the ISDATE function is not a reliable method for such validation.

    DECLARE

    @InputDate DATETIME

    ,@CurrDate DATETIME

    SET @InputDate = '1/1/2013'

    SET @CurrDate =...

  • RE: Group By Inside CASE Statement

    There's really no limit to what you can do with grouping and case statements. The OVER() clause really makes thing easy. You can even combine all the aggregates in the...

  • RE: Group By Inside CASE Statement

    You can avoid group by altogether by using the OVER() method when using aggregates (I think this is for SQL2008 and higher).

    IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL

    DROP TABLE #TempTable

    CREATE TABLE #TempTable...

  • RE: Nested replaces ?

    Wow...I'm impressed! I don't think the OP realized the impact of his request! The more I think about this the more uses I can see for such a function. For...

  • RE: Nested replaces ?

    ChrisM@Work (1/22/2013)


    dwain.c (1/22/2013)


    Uh, just asking here but wouldn't it make sense to vary the strings and the replacements?

    Or did I miss something?

    Not often you miss something Dwain! You're right of...

  • RE: Nested replaces ?

    Here's my variation to do a dynamic replace of elements from one delimited string by another. It's really just a variation of DelimitedSplit8K. Just out of curiosity I ran it...

  • RE: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    aochss (1/16/2013)


    I would not expect a record back if the string being sent in is NULL, a single space or all spaces. In my case, I have records...

  • RE: Optimizing XML import in SQL Server

    For future reference, you may want to parse the entire XML string into its own table in one pass and then construct your query around that to join with the...

  • RE: ORDER BY non-sequential number sequence

    Here's another alternative you could try:

    IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL

    DROP TABLE #TempTable

    CREATE TABLE #TempTable (

    [ID] [int] IDENTITY(1,1) NOT NULL,

    [FirstName] [nvarchar](50) NULL,

    ...

  • RE: SELECT vs INSERT INTO

    Bhuvnesh (1/14/2013)


    i think "insert into select " provide better readabilty when we use this approach in "long time used queries/stored proc". we can easily see what are the columns and...

  • RE: Need to find out whether date is of which data type

    ScottPletcher (1/10/2013)


    dwain.c (1/9/2013)


    Steven - Those FUNCTIONs look like nice work. I've saved them off for future analysis. 🙂

    You might want to review the new functions in SQL 2012 dealing...

  • RE: Need to find out whether date is of which data type

    AS you've found out, the use of ISDATE is unreliable when doing implicit conversions.

    Try these:

    SELECT ISDATE('2013-01-08 15:44:12.2081606 +05:30') AS test

    SELECT ISDATE('2013-01-08 15:44:12.2081606') AS test

    SELECT ISDATE('2013-01-08 15:44:12.208') AS test

    The different results...

  • RE: Sequential YYYYMM calc problem

    To get the correct week number based on ISO standard you can use this function:

    --Credit to Ramakrishna Elashwarapu

    CREATE FUNCTION dbo.tvfGetWeekNumberFromDate_ISO

    (

    @dDate DATETIME

    ...

Viewing 15 posts - 301 through 315 (of 423 total)