Forum Replies Created

Viewing 15 posts - 331 through 345 (of 475 total)

  • RE: Trying to understand this SQL Query

    Oracle765 (6/18/2013)


    Hi all

    yes i agree, i am not sure about the left out join thats what has confused me a bit.

    would this query provide the same results?

    SELECT distinct a1.Netbios_Name0,

    c1.SerialNumber0,...

  • RE: Table 1 New Record Autocounter field value copied to Table 2 and creates new record

    Another option for your trigger could be

    CREATE TRIGGER [dbo].[R_CopyNewAuditID]

    ON [dbo].[Audit]

    AFTER INSERT

    AS

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets...

  • RE: Trying to understand this SQL Query

    Hi

    I may be wrong, but I can't see a reason for this join

    left outer join v_GS_CCM_RECENTLY_USED_APPS d1

    on b1.ResourceID = d1.ResourceID

    and b1.GroupID = d1.GroupID

  • RE: Query to delete the records with top 3 marks from a student table

    Hi

    How do you want to deal with records that have the same marks?

    For Example

    SELECT *

    FROM (VALUES

    (99, 'Jim')

    ,(99, 'Joe')

    ,(97, 'Jock')

    ,(97, 'John')

    ,(96, 'Jack')

    ,(96, 'James')

    ,(96, 'Jeremy')

    ,(50, 'Jeb')

    ) m (Mark, Student)

    Would you remove...

  • RE: Create FirstName and LastName to Replace Existing FirstName and LastName

    Here's another option

    with sampleData as (

    SELECT FirstName, LastName, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) N

    FROM (VALUES

    ('Robin','Bacon'),

    ('Owen','Twomey'),

    ('James','Kendall'),

    ('John','Cavanagh'),

    ('Lola','Oxborough'),

    ('Thomas','Archibald'),

    ('Mathias','Kearns'),

    ('Christine','Winger'),

    ('Barry','Kane'),

    ('Rereahu','Gray'),

    ('Douglas','Christian'),

    ('Jennifer','Clark'),

    ('Kenneth','Court'),

    ('Paul','Pedersen'),

    ('Bruce','McKelvie'),

    ('David','McCrary'),

    ('Paul','Allison'),

    ('Linda','Cawthorn'),

    ('Noelene','Schellhorn'),

    ('Patricia','Pedersen'),

    ('Ivan','Hill'),

    ('Stewart','Leys'),

    ('James','Austin'),

    ('Roger','McManaway'),

    ('Katherine','Edmonds'),

    ('Bryan','Wilson'),

    ('James','Jones'),

    ('William','Healey'),

    ('Caroline','Rae'),

    ('Stephen','Mullins'),

    ('Graeme','Gray'),

    ('Gary','Gibbens'),

    ('Annie','Oxborough'),

    ('Emma','Kennedy'),

    ('Patricia','Wii'),

    ('Raymond','Winger'),

    ('Judith','Owen'),

    ('Ruby','McCrary'),

    ('Peter','Waterhouse'),

    ('Gaye','Cox'),

    ('Barbara','Hill'),

    ('Jeanette','Patchett'),

    ('Norman','Forbes'),

    ('Andrew','Forsyth'),

    ('Aldyth','Edmonds'),

    ('Mick','Stohr'),

    ('Nicola','Howie'),

    ('Linda','Gray'),

    ('Fenella','Silva'),

    ('Allan','McCandless'),

    ('Gillian','Scott'),

    ('Garth','Woodcock'),

    ('Peter','Woodcock'),

    ('Fenella','Waterhouse'),

    ('Patricia','Leys'),

    ('Paul','Sykes'),

    ('Richard','Fortzer'),

    ('Dean','McKelvie'),

    ('Cuan','Fortzer'),

    ('Vaughan','Heymons'),

    ('Donald','Toseland'),

    ('Alan','Sclater'),

    ('Nancy','Ollerenshaw'),

    ('Eddie','Buhler'),

    ('Lewis','Taylor'),

    ('Kerin','Medland'),

    ('Carlton','Forsyth-King'),

    ('Opie','Cleland'),

    ('Gail','Oshannessy'),

    ('Stuart','Gray')

    ) AS N (FirstName, LastName)

    )

    ,RandFirstName AS (SELECT FirstName, ROW_NUMBER() OVER (ORDER BY RAND(CAST(NEWID() AS VARBINARY)))...

  • RE: Random Number Generator

    dwain.c (6/3/2013)

    Now if I can just figure out how to export that so I can keep in sync the various SQL servers I operate on, I'd be happy as a...

  • RE: Flagging Records within a table of sequenced numbers

    rossnruthie (5/30/2013)


    ...

    Method 2(Micky) works well for the most part but will return a false positive where it finds a record with the am_sw flagged and less the 7 records following...

  • RE: Export table with Geography data type

    Hi

    You could try transferring the data over as a varbinary(max). You would need to specify a query where you cast the Geography column as a varbinary(max) rather than...

  • RE: Flagging Records within a table of sequenced numbers

    rossnruthie (5/30/2013)


    You guys are awesome! Just please tell me you've had to deal with this before and that is why you came up with a solution so quickly :-P....

  • RE: Flagging Records within a table of sequenced numbers

    And another possible method:-)

    select i.number

    from @numbers i

    where am_sw = 1

    and not exists (

    SELECT 1 cc_sw_sum

    FROM @numbers ca

    WHERE i.number = ca.number

    and ca.sequence_number - i.sequence_number...

  • RE: GeoSpatial Data Types

    Hi

    As Grant said the Geography (and Geometry) datatypes are design to store and manipulate sets of coordinates. They can't be used to store an ordinate.

    I guess the question is...

  • RE: Can you delcare an operator?

    Hi

    You might be able to create a function to handle it, eg:

    CREATE FUNCTION dbo.myOpCarYear (@op varchar(2), @value varchar(4)) RETURNS TABLE AS

    RETURN

    (SELECT CARS.Year FROM CARS WHERE @op = '<>'...

  • RE: Query Sum

    Hi

    You could try the following, I wouldn't expect the performance to be the best because of the partition on the RIGHT function. It may be worthwhile making the making...

  • RE: How do I use an IF type function within a SELECT statement?

    Sean Pearce (5/21/2013)


    If the columns are nullable then you can concatenate.

    ...

    SELECT

    ISNULL(House_No_Start, '') + ISNULL(' - ' + House_No_End, '') + ISNULL(House_Name, '') AS House

    FROM

    House;

    ...

    I frequently use (and prefer) the method...

Viewing 15 posts - 331 through 345 (of 475 total)