Forum Replies Created

Viewing 15 posts - 46 through 60 (of 149 total)

  • RE: New Records are not inserting into tables

    instead of just doing a select all into the table:

    INSERT INTO Table1

    SELECT * FROM Table2

    You might want to try a not exist in a where clause:

    INSERT INTO Table1

    SELECT *

    FROM Table2...

  • RE: Last 6 Month Qty for each Row

    Try this:

    DECLARE @vcStart varchar(6),

    @vcEnd varchar(6)

    SET @vcStart = CONVERT(char(4), YEAR(DATEADD(month, -6, GETDATE()))) + RIGHT('00' + CONVERT(varchar(2), MONTH(DATEADD(month, -6, GETDATE()))), 2)

    SET @vcEnd = CONVERT(char(4), YEAR(GETDATE())) + RIGHT('00' + CONVERT(varchar(2), MONTH(GETDATE())), 2)

    SELECT Whse_Code, SUM(Sales_Qty) AS...

  • RE: Sort question with a date

    Try using your select statement as derived table like the following:

    SELECT ID,

    [Date],

    TimeGroup,

    CallCount

    FROM (SELECT 1 AS ID, -- dummy value

    CONVERT(VARCHAR(10), s.endtime, 101)...

  • RE: UPDATE using a HAVING

    Try this:

    UPDATE t

    SET points = points + 1

    FROM #Temp6 t

    INNER JOIN (SELECT ConsultantId

    FROM volume

    GROUP BY ConsultantId

    HAVING SUM(PurchaseAmount) > 1000) v

    ON t.ConsultantId = v.ConsultantId

    WHERE DeactivationDate BETWEEN @StartDate AND @EndDate

    AND Active =...

  • RE: trim last character in a string for all records in a column

    Check out the SUBSTRING function.

    It takes three parameters:

    1. The expression to search

    2. The start place of what to return

    3. The length of characters to return. In...

  • RE: Problem with Join/Where

    This one is going to be a little more difficult. You are going to have to combine the date and time into a datatime field and then find the...

  • RE: SQL Server 2K5 on VMWare

    This all has been some very good food for thought. It looks like the hardware folks here at my company are going to go the way of either a...

  • RE: Problem with Join/Where

    Using the derived tables is one solution. Here is another that looks very similiar:

    SELECT p.name, p.dob, c1.charge, c2.charge, c3.charge

    FROM patients p

    LEFT OUTER JOIN charges c1 ON...

  • RE: SQL Server 2K5 on VMWare

    Michael,

    Thanks for the info. We are using the ESX licensed version of VMWare. We have run into quite a few problems with the freeware version on other applications...

  • RE: in and not in question

    Matt,

    Would not an 'EXISTS' clause be cleaner and more efficient in this situation or not? I am just asking this because I am curious, and I have been seeing...

  • RE: "Subquery returned more than 1 value." error

    I have a feeling you are using an '=' in your camparison to the subquery. Try using an 'IN' instead. This way it will compare the left side...

  • RE: How do I split import data from excel to 2 tables?

    Two ways that I can think of are:

    1. import the data into a staging table that has an identity column and then run two insert statements to split the...

  • RE: in and not in question

    Another possibility is using the exists and not exists clause

    in place of your {not in} clause try this:

    select * from tableA a

    where not exists (select null from tableB where id...

  • RE: BRAKING A COLUMN INTO TWO

    Yes, you can apply it to the entire column. Here is an example of an update sql that take a full name and parse it into the first and...

  • RE: dynamic sql in a function

    If you will always be checking the same table, then there is a way to create a function to check a particular passed in column for a particular passed in...

Viewing 15 posts - 46 through 60 (of 149 total)