Forum Replies Created

Viewing 15 posts - 1 through 15 (of 23 total)

  • RE: Simple SQL Question (i think)

    It still isn't needed.  The example below shows a join without a derived table to get whatever info you want.  I only checked for dups in the firstname/lastname fields because that...

  • RE: Lookup Table Madness

    I don't like MUCK tables even though I have used them and inherited them.  The integrity just isn't there.

    The only advantage is that they require only 1 screen in the...

  • RE: table naming conventions

    I would also recommend that you use a standard across the database.

    The two most common ways are:

    • All lowercase with underscores between the words percent_sold
    • Uppercase for the first letter of each...
  • RE: Need Quick Answer---Calc Date for Under 18

    I think this does it.

    declare @birth smalldatetime

    declare @now smalldatetime

    select @birth = '3/22/1988'

    -- Gets todays date without the time

    select @now = convert(varchar(12),getdate(),101)

    if (dateadd(yy,-18,@now) >= @birth)

      select 'older than 18'

    else

      select 'younger...

  • RE: displaying the text inside a sproc

    You could also script the stored procedures out of the db using the generate sql script functionality.  This can script them to one file where you could use find.  You...

  • RE: Simple SQL Question (i think)

    A derived table is not needed here.  Just run this query

    SELECT FirstName, MiddleName, LastName, DateOfBirth

    FROM table

    GROUP BY Firstname,

    MiddleName

    LastName

    DateOfBirth

    HAVING count(*) > 1

  • RE: copying from one database to another - but only new data?

    Might as well give you the not exists option as well

    INSERT INTO table1

    SELECT * FROM table2 t2 WHERE NOT exists (SELECT 1 FROM table1 t1 where t1.id = t2.id)

  • RE: what''''s my slow proc doing?

    Create a table with two columns. One will be where in the process the sp is the other is the time. Now go to your proc and throughout...

  • RE: SQL Query for a recursive relation (bad subject...)

    The script I posted does what you are wanting. Is there some reason it won't work?

    Chris

  • RE: should I use "barcodes" as a primary key?

    Since no one else is doing it, here goes the identity argument.

    Use an identity. Also create a unique index on the vendor/bar code columns. Everyone here...

  • RE: SQL Query for a recursive relation (bad subject...)

    Here is what I came up with. Basically if you have a recursive relationship, you have to walk down it. You can use a cursor or a while...

  • RE: Maths functions on subqueries

    This should do it...

    SELECT dt.*,

    case when RenewalsDue = 0 then 0

    else (NumberRenewed * 100.0) / RenewalsDue end As PercentRenewed

    FROM

    ( -- derived table starts here

    SELECT ...

  • RE: Optimized SQL Statement

    I agree with a previous post about the size of the tables. If table3 has 10 million rows, why not check for existence in the student table. Of...

  • RE: Sql case statements..

    The case statement is used in the select clause not the join clause. i think what you are trying to do is accomplished by the following code.

    CREATE PROCEDURE prcTestCase

    (@BeginDate...

  • RE: Why same stored procedure getting slower ??

    Is your inner cursor performing an update? What is the sp doing?

Viewing 15 posts - 1 through 15 (of 23 total)