Forum Replies Created

Viewing 15 posts - 1,651 through 1,665 (of 3,957 total)

  • RE: Need Help Urgently

    Something like this should list out any of the products that fail your audit.

    WITH ValidationTables (n, )

    SELECT 1, [Key] FROM A

    UNION ALL...

  • RE: tsql function with dynamic number of parameters?

    Steven - Your posting gave me the idea for this (your Tally FUNCTION):

    CREATE FUNCTION [dbo].[itvfTally]

    (

    @pMin BIGINT

    ,@pMax BIGINT

    ...

  • RE: tsql function with dynamic number of parameters?

    Although the syntax is not the same, you could DECLARE a TYPE that is a TABLE and pass that into the FUNCTION.

    You then just assign each value to a row...

  • RE: What is Cross Apply ?

    Here are some additional links:

    Understanding and Using APPLY (Part 1)[/url] by Paul White

    Understanding and Using APPLY (Part 2)[/url] by Paul White

    The Cascading (CROSS) APPLY[/url] by Chris Morris

    And don't miss the...

  • RE: select distinct

    Here's another way. Just uncomment your code and comment out the sample data.

    WITH CTE (NMDOS, ETOTALDEB, tpdesc, dataobra, NOME, OBRANO, nmdoc, FNO, etiliquido)

    AS (

    --SELECT distinct BO.NMDOS,bo.ETOTALDEB, bo.tpdesc ,bo.dataobra,BO.NOME ,BO.OBRANO,ft.nmdoc,FT.FNO,CASE...

  • RE: Help - Shredding XML

    Here's one way. Not sure it's the best way and it doesn't use OPENXML though:

    DECLARE @Books XML = '

    <bookstore>

    <book>

    ...

  • RE: Trying to convert varchar to datetime

    Jeff Moden (7/24/2013)


    savycara (7/24/2013)


    DECLARE @d varchar(6) = '20114'

    SELECT try_convert(date, substring(@d, 1, 4) +

    CASE WHEN len(@d) = 5 THEN '0' ELSE '' END +

    substring(@d, 5, 2) + '01')

    This worked but...

  • RE: Case statement

    Why use a CASE at all?

    WITH Rates (rate) AS (

    SELECT -100 UNION ALL SELECT NULL UNION ALL SELECT 0

    UNION ALL SELECT...

  • RE: Trying to convert varchar to datetime

    Ignoring the try_convert (which is probably a good idea), I think this may be another way:

    SELECT CONVERT(VARCHAR(10), CAST(STUFF('201311',5,0,'-0')+'-01' AS DATETIME), 101)

    ,CONVERT(VARCHAR(10), CAST(STUFF('20131',5,0,'-0')+'-01' AS DATETIME), 101);

  • RE: Trying to convert varchar to datetime

    HanShi (7/24/2013)


    Because additional digits are required to get a valid date notation, the conversion fails. You need to add additional prefixing to get a valid numeric value of at least...

  • RE: Finding unequal column values with multiple column comparison

    ColdCoffee (7/24/2013)


    Glad that it worked. I hope you understand the power of providing ready-to-use sample data. It makes the life of forum members a lot easier to work on the...

  • RE: Finding unequal column values with multiple column comparison

    SELECT a.Col1, a.Col2, a.Col3, a.Col4

    FROM #TableA a

    LEFT JOIN #TableB b

    ON a.Col1 = b.Col1 AND a.Col2 = b.Col2 AND

    ...

  • RE: First, Last row and other data from those rows

    Just for a little variety, I think this is another way:

    SELECT a.ID, Cat -- , [Date], [Type]

    ,[FirstDate]=MIN([Date])

    ,[FirstType]=MAX(CASE WHEN a=[Date] THEN [Type] END)

    ...

  • RE: Trying to convert varchar to datetime

    I guess that would depend on exactly what date you think 20114 represents.

    SELECT '20114', CAST('20114'+0 AS DATETIME)

  • RE: Rows for last week

    I'd say that if you want this

    SELECT DATEADD(week,DATEDIFF(week,7,GETDATE()),0)

    To always return the Mon of the prior week, it works pretty well.

    SET DATEFIRST 1

    SELECT DATEADD(week,DATEDIFF(week,7,GETDATE()),0)

    SET DATEFIRST 7

    SELECT DATEADD(week,DATEDIFF(week,7,GETDATE()),0)

    SELECT DATEADD(week,DATEDIFF(week,7,'2014-01-15'),0)

    SELECT DATEADD(week,DATEDIFF(week,7,'2012-03-15'),0)

Viewing 15 posts - 1,651 through 1,665 (of 3,957 total)