Forum Replies Created

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

  • RE: Select Latest record by comparing 2 tables.

    In the combined cte just add a where clause to both tables to filter out the null records.

  • RE: Select Latest record by comparing 2 tables.

    Old school query without CTE and windowing functions:

    SELECT MachineID, InstanceKey, TimeKey, RevisionID, rowversion, Account, SchemaClass FROM TABLE_A

    where not exists(

    SELECT TABLE_B.MachineID FROM TABLE_B

    where TABLE_B.MachineID = TABLE_A.MachineID

    and TABLE_B.InstanceKey = TABLE_A.InstanceKey

    and TABLE_B.TimeKey >...

  • RE: AS400 unreadable results

    This appears to be data encoded in EBCDIC format. Some type of translation into the ASCII char set would be required. You may not be able to connect...

  • RE: t-sql 2012 self joins

    8 years ago I also was asked to work on "EAV Magic" system. "EVA Magic" was not quite as extreme as "vision". It stored the meta data in...

  • RE: OPENROWSET - how to read everything as text

    If do try and use a *.csv (Comma Separated Values) driver it will probably work better on data like this:

    IntColumn1 CharColumn2 CharColumn3

    1,"Row1Col2","Row1Col3"

    2,"Row2Col2","Row2Col3"

  • RE: OPENROWSET - how to read everything as text

    In the olden days we did this kind of thing with BCP. This still works ok for ad hoc imports, but it is not the easiest tool in the...

  • RE: Can we delay the execution?Or ReWrite this Query?

    As a general rule I don't like putting business logic in triggers if there is any other reasonable way to accomplish the result. If the logic in your function...

  • RE: Query Runs slow after changing the value

    whoops I did not move the order by.

    SELECT

    Prod.*,

    ProdInfo.*,

    dbo.NetPortal_GetProductPrice(externalId,'LIST', ProdInfo.PPRO_SubSystem) ListPrice,

    dbo.NetPortal_GetProductPrice(externalId,'MEMBER', ProdInfo.PPRO_SubSystem) MemberPrice

    FROM NetPortal_Ecommerce_Categories Cat

    INNER JOIN NetPortal_Ecommerce_ProductCategory_Link CatLink ON

    CatLink.CategoryId = Cat.ID

    INNER JOIN NetPortal_Ecommerce_Products Prod ON

    Prod.ID =...

  • RE: Query Runs slow after changing the value

    try this:

    SELECT

    Prod.*,

    ProdInfo.*,

    dbo.NetPortal_GetProductPrice(externalId,'LIST', ProdInfo.PPRO_SubSystem) ListPrice,

    dbo.NetPortal_GetProductPrice(externalId,'MEMBER', ProdInfo.PPRO_SubSystem) MemberPrice

    FROM NetPortal_Ecommerce_Categories Cat

    INNER JOIN NetPortal_Ecommerce_ProductCategory_Link CatLink ON

    CatLink.CategoryId = Cat.ID

    INNER JOIN NetPortal_Ecommerce_Products Prod ON

    Prod.ID = CatLink.ProductId

    AND (Prod.AvailableDate IS NULL OR...

  • RE: rolling 12 months

    No problem

  • RE: rolling 12 months

    I would agree that the clustered index should be chosen carefully. Too many people just make it the primary key identity column. On an OLTP system this is...

  • RE: rolling 12 months

    Again it is hard to assist here because you don't list a table structure. Your solution is using columns that don't exist is your sample data. You also...

  • RE: rolling 12 months

    It helps if you put a table def in your question.:Whistling: Assuming Yearmm is an int this will work.

    declare @endDate datetime=getdate()

    declare @startDate datetime

    set @startDate = dateadd(mm, -12, @endDate)

    -- validate...

  • RE: Best way to merge two large client databases

    If you want and even more difficult task, try explaining to management types why this is not simple and easy thing to do.

    Adding a fixed amount to identity keys can...

  • RE: Writing Better T-SQL: Top-Down Design May Not be the Best Choice – Part II

    Rather than using views I have often used Table Value Functions to achieve modularization. I first write a lower level detail function that does the filtering and returns detailed...

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