Forum Replies Created

Viewing 15 posts - 16 through 30 (of 275 total)

  • RE: how many variables can I have?

    I agree: AFAIK, the only restriction on the number of variables is memory space.

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: order result selected by LIKE

    Maybe:

    ORDER BY LEN( Number ) DESC

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: Using Case or If Else statements within joins

    It sounds as if you do need two LEFT OUTER JOINs, as Wayne suggested.

    Other than that, sorry, I give up. Hopefully s/o else can help you.

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: Using Case or If Else statements within joins

    Please try running this:

    SELECT glbank.check_num

    , glbank.ref_num

    , glbank.check_amt

    , glbank.check_date

    , glbank.bank_code

    , vendaddr.[name]

    , vendor.vend_num

    , vendor.vend_remit

    FROM((aptrxp_all

    INNER JOIN glbank

    ON aptrxp_all.check_num=glbank.check_num)

    INNER JOIN vendaddr

    ON aptrxp_all.vend_num=vendaddr.vend_num)

    INNER JOIN vendor

    ON (vendaddr.vend_num IS NOT NULL AND...

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: Understanding JOINS

    Yes, that's right.

    You could consider the LEFT/RIGHT table as the "always" side of the JOIN, with the other, un-named side being the "optional" side.

    So, back to your q 2), breaking...

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: Using Case or If Else statements within joins

    INNER JOIN vendor

    ON (vendaddr.vend_num IS NOT NULL AND vendaddr.vend_num=vendor.vend_num)

    OR (vendaddr.vend_num IS NULL AND vendaddr.vend_remit=vendor.vend_remit)

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: Output formatting

    Use CONVERT:

    SELECT LEFT(CONVERT(varchar(16), amount, 1), LEN(CONVERT(varchar(16), amount, 1)) -3) AS Amount

    FROM (

    SELECT CAST(1234567.8901 AS money) AS amount

    UNION ALL

    SELECT...

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: resume after error for primary key violation

    Of course if the duplicates are both in the same batch you are inserting -- which sounds extremely likely in the scenario you are presenting -- that code won't solve...

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: Query slow

    @scott:

    If Results holds other values than 0 to 3, the COUNT(*) in your query would show a different result than what the OP currently will get.

    Quite. I...

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: Query slow

    You might add one further refinement to Lutz's excellent query, depending on whether Results column could ever have other values:

    SELECT

    COUNT(*)...

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: fork a process

    You could use a trigger on a custom table built to allow it to fire off other procs with params.

    That's not especially easy or clean, but it will work.

    It's difficult...

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: Using the salary table on the left, write a SQL Server T-SQL query to find the Top 2 salaries for each employee. The result of the query is on the right.

    Does your book tell you what version of SQL Server? If it's SQL 2000, the answer will be different.

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: How long has passed since SQL Server service started?

    Very nice! You can shorten it up a bit though 🙂

    DECLARE @minutesSinceSQLStarted int

    SELECT @minutesSinceSQLStarted = DATEDIFF(MINUTE,

    -- determines when tempdb was created (done at startup) ...

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: IN operator only returning first match

    AND fs.Currency IN (SELECT item FROM dbo.ABN_fnSplitChar(@Currency,','))

    Maybe the 'GBP' row(s) are being excluded by another condition ... this does start with "AND" 🙂

    Scott Pletcher, SQL Server MVP 2008-2010

  • RE: select a record based on a time range

    From a performance standpoint, are you better off putting the calcs on GETDATE() directly in the SQL rather than using variables? I would hope that SQL's optimizer would realize...

    Scott Pletcher, SQL Server MVP 2008-2010

Viewing 15 posts - 16 through 30 (of 275 total)