Forum Replies Created

Viewing 15 posts - 1,276 through 1,290 (of 1,418 total)

  • RE: Insert/Update

    Assuming the PK is (Site, Item), try something like the following:

    -- Insert

    INSERT INTO preferred_supplier

    SELECT SITE, ITEM, PREF_SUPPLIER, [DESCRIPTION]

    FROM pref_temp T

    WHERE NOT EXISTS (

     SELECT *

     FROM preferred_supplier S

     WHERE S.Site = T.Site AND...

  • RE: Substracting dates to give year.

    You need to use CONVERT instead of CAST.

    The style will be 101 for US dates or 103 for UK dates.

    Ideally you should alter the table so that dates are stored...

  • RE: Differenc between two record sets

    -- Simple; assuming no time component in date and consecutive days

    DECLARE @t TABLE

    (

     tDate datetime NOT NULL

     ,Client int NOT NULL

     ,A int NOT NULL

    )

    INSERT INTO @t

    SELECT '20061101', 1, 100 UNION ALL

    SELECT '20061102',...

  • RE: Stored Proc with Dyanmic SQL - Headache

    I am glad my efforts sort of worked!

    You are correct, those horrible multi-valued columns need to be dealt with. The following link may give you some...

  • RE: HELP WITH A SIMPLE STORED PROCEDURE

    Asim,

    >>can you tell me how should i take care about this logic below in my stored procedure

    As you have failed to give a cogent description of what you are trying...

  • RE: HELP WITH A SIMPLE STORED PROCEDURE

    Asim

    Microsoft SQL Server is a relational database so rows in a table should have NO order. (Basic theory.) There often is some order but this cannot be guaranteed!

    The...

  • RE: decimal places are being rounded to zero

    If the accuracy of a FLOAT is alright, then just force a FLOAT by adding a decimal point to one of the numbers.

    eg. set @Size...

  • RE: Stored Proc with Dyanmic SQL - Headache

    Carl,

    I see no need for dynamic SQL here as the only thing you are adding to the string is @Crit_Label.

    To speed this procedure up I suggest you:

    1. Convert to static...

  • RE: Transforming a table - logic question

    If possible, normalize the schema although a reporting tool should be able to cope with the current table structure.

    To get the output requested, something like the following should work:

    SELECT

     T.Item_ID

     ,T.Year_ID

     ,N.Nbr AS...

  • RE: Converting date of birth to Age

    Farrell,

    I think the difference is that your quick age calculation just uses the difference in years. As all your BirthDates are in December you should really minus one from the...

  • RE: HELP WITH GROUP BY CLAUSE-URGENT

    You need to group by the formula for TableValue:

    INSERT INTO ClaimCounts (Month_of_file, CalcAction, TableValue, CalculatedValue)

    SELECT

     @Month_of_file_filter AS Month_of_file

     ,'Record Count by Loss Month' AS CalcAction

     ,CONVERT(varchar(4), LossDate, 120) AS TableValue -- change...

  • RE: old non-Y2K software, need ''''update year'''' in date field

    You cannot assign a value to a function. Try something like:

    UPDATE CUSTOMERS

    SET [DATE] = DATEADD(year, 100, [DATE])

    WHERE YEAR([DATE]) BETWEEN 1900 AND 1999

     

  • RE: Converting date of birth to Age

    There are probably better ways, but something like this should work in both SQL2000 and SQL2005:

    SELECT CASE

     WHEN D.Age BETWEEN 20 AND 29 THEN '20-29'

     WHEN D.Age BETWEEN 30 AND 39 THEN...

  • RE: Using Calculated Field/Case Labels in other Calculated/Case Fields

    You can do it via a derived table:

    SELECT

     D.UM

     ,D.UM_DIV

     ,D.UM_DIV * D.QTYORD AS UnitNum

    FROM (

     SELECT S.UM

      ,S.QTYORD

      ,CASE S.um

      WHEN 'ea' THEN 1

      WHEN 'bx' THEN 10

      ELSE 2 END AS UM_DIV

     FROM Sales S ) D

     

  • RE: 10 minutes stored procedure now runs hours and hours

    You could try checking to see if any of the VIEWs point to a different server.

    Also, as you do not seem to be using any aggregate functions, you could remove...

Viewing 15 posts - 1,276 through 1,290 (of 1,418 total)