Forum Replies Created

Viewing 15 posts - 76 through 90 (of 152 total)

  • RE: Nested Subquery

    I agree that a Derived table is your best way. I would probably use:

    SELECT DISTINCT DeniedCharge, Account, DenialDate, DenialCode

    FROM DenialStore

    This should return the equivalent of one, and only one,...

  • RE: Last Business Day of Each Month

    You can try this UDF - it should do what you need:

    Create Function dbo.ufn_LastBusinessDayOfMonth(

    @dt datetime

    )

    RETURNS datetime

    AS

    BEGIN

    Declare @dt2 datetime

    Declare...

  • RE: Last Day of each month function?

    What a great function set - and it truncates off any minutes as well!

    Two thumbs up!

  • RE: T-SQL Help

    You should be able to do this in one statement, e.g.:

    Select a.EffectiveDate As StartDate,

    (Select Min(x.EffectiveDate) FROM MyTable x WHERE x.EffectiveDate > a.EffectiveDate) As EndDate, a.Code1, a.Code2

    FROM...

  • RE: DTS failing as a job

    As shown, this will be using, not the windows login of the job (or you), but a login chosen as follows:

    When xp_cmdshell is invoked by a user who is a...

  • RE: Last Day of each month function?

    Just as a heads-up, you will probably be better off just appending '01' to the existing data string you have, rather than using the mm/dd/yyyy format. yyyymmdd is an...

  • RE: Date error in Stored Procedure

    CAST or CONVERT the variables to datetime, e.g.:

    where datesold between Cast(@startdate as Datetime) and Cast(@startdate as Datetime)

  • RE: Quick Ques about variables & speed...

    Okay - I am going to play with the query optimizer's mind here:

    SELECT * From (
    SELECT *, 'a' AS Filter
    FROM tbl_a
    INNER JOIN tbl_b
    ON tbl_a.index = tbl_b.serial
    WHERE tbl_a.row_id = @row_id  
    UNION
    SELECT...
  • RE: transactions & multicurrency

    Well, the basic query structure is fairly straightforward. Your big problem is the first transaction, which has a date before the first entry in your Exchange Rate table.

    The correct way...

  • RE: Quick Ques about variables & speed...

    A quick run through Query Analyzer would probably tell you more than I can, but I would believe that the conditional field check would cause the analyzer to miss the...

  • RE: Just a simple question

    You are correct in your first supposition -- you need to restore both Log backups.

    REASON:  One of the things that log backups do is to signal to SQL Server that...

  • RE: scope_identity

    Marco has a valid point.  However, you probably should just embed the SQL call into a Stored procedure, and return the Identity from that SP, e.g.:

    CREATE PROCEDURE usp_MyStoredProc

    @Param1 int, @Param2...

  • RE: Restoring master on an instance causes problems

    Your code does not include the MOVE parameter.  Thus, by default, the .MDF and .LDF files are placed in the same physical location for both DBs, because RESTORE extracts that...

  • RE: Restoring master on an instance causes problems

    Best bet:

    Where are you restoring the DB files to?  If you forgot to alter the destination of the .MDF/.LDF files on restore for the second instance, they will default to...

  • RE: BLOB datatype

    In SQL Server, the datatype names are a bit different:

    BLOB = Image

    CLOB = Text or NText

    So, to create a BLOB:

    CREATE TABLE MyTable (MyBLOB image)

     

Viewing 15 posts - 76 through 90 (of 152 total)