Forum Replies Created

Viewing 15 posts - 3,196 through 3,210 (of 3,500 total)

  • RE: Date Help

    Great! Glad to help.

    When in doubt, test it out in TEMPDB.

    Either use

    USE TEMPDB;

    GO

    ... and then paste your code here

    OR prefix the tablename with a # sign....

    CREATE TABLE #TableInTempDB...

  • RE: Date Help

    This pretty much explains it -- just run the queries and see what happens:

    USE tempdb;

    GO

    CREATE TABLE SomeDates(TheDate DATE);

    INSERT INTO SomeDates VALUES('1/11/2014');

    INSERT INTO SomeDates VALUES('1/12/2014');

    INSERT INTO SomeDates VALUES('1/13/2014');

    INSERT INTO SomeDates VALUES('1/14/2014');

    INSERT...

  • RE: Date Help

    Do you mean 'Does it matter the order in which I declare variables and assign them values?' No. Not unless one is dependent upon another.

  • RE: Need to find date of Nth crash for every car_make in every country

    Not sure if this will help if you're querying a DW... this is one way:

    SELECT c.CarMake

    , c.Country

    , c.EventDate

    , c.RowNum

    FROM

    (SELECT CarMake

    , Country

    , EventDate

    , ROW_NUMBER() OVER (PARTITION BY CarMake, Country ORDER...

  • RE: Newly Migrated backend DB

    Inside Access, right-click on one of your linked tables, select Linked Table Manager from the menu, and it will show you where the tables are pointing to.

  • RE: Return random records in a table-valued function?

    Thanks for the help. I think it's closed. I tested it with grade 4, just to short-circuit the record creation, since the "fatal" grade is somewhat arbitrary. ...

  • RE: Show only Parent and 1st Child

    You're welcome... if you run my code, make sure the CREATE TABLE code for Protocol is before the code for Enroll. (That part was confusing in my post, I...

  • RE: Show only Parent and 1st Child

    You can do it using CROSS APPLY.

    Read these two articles (definitely worth the read!):

    http://www.sqlservercentral.com/articles/APPLY/69953/ (Part I)

    http://www.sqlservercentral.com/articles/APPLY/69954/ (Part II)

    (Basic plan)

    Get the TOP 1 Values from the child table (pass...

  • RE: varchar to int scenario

    "I cover this in my Common TSQL Mistakes SQL Saturday session..." (just not #272? Not coming to NashVegas?? Drat!

  • RE: Moving SQL Server db and associated classes

    And don't forget MSDB. That's where all your jobs etc are stored.

    Before the original server goes away, make sure you have a working SQL Server instance where you need...

  • RE: Return random records in a table-valued function?

    okay... I think this fixes the "you can't report symptoms after you're dead" issue...

    CREATE VIEW vwEnrolleeFatalCycle

    AS

    SELECT enrollmentID

    , MIN(cycle) AS FatalCycle

    FROM Symptom INNER JOIN Data ON Symptom.SymptomID = Data.ID

    WHERE Grade =...

  • RE: Cursor Help

    Okay, here's the DELETE as a CTE, which is probably the easiest way to do it... (once you read the crib notes)

    ; WITH CTE_DupeAddr(DupeID, ID, Cid, FName, LName, DOB, City)...

  • RE: Cursor Help

    So sue me.

    --Mark the records we want to delete, just to be sure we don't do anything terrible.

    UPDATE #TableA

    SET IsActive = 1

    WHERE [SID] IN

    (SELECT MIN([SID]) AS GoodID

    FROM #TableA

    GROUP BY ...

  • RE: Cursor Help

    So in theory they could merge two records that don't match? Could you post an example? Explain why you can't do it with either a CTE or a...

  • RE: Cursor Help

    Cursor is a bad word around here... careful.

    That said, I don't think you need a cursor at all.

    CREATE Table #TableA

    (

    ID int IDENTITY(1,1),

    SID INT,

    FNAME varchar(50),

    LNAMEvarchar(50),

    DOB date,

    CITYvarchar(50),

    IsActive bit

    );

    GO

    INSERT INTO #TableA

    VALUES ('245','Smith','John','1/10/1998','Los Angles','0');...

Viewing 15 posts - 3,196 through 3,210 (of 3,500 total)