Forum Replies Created

Viewing 15 posts - 121 through 135 (of 444 total)

  • RE: Help me to write a query

    Try this one

    ;WITH mas as(

    select Max(mas.Time) as [Time]

    from RealtimeData mas

    GROUP BY convert(nvarchar,mas.Time,103)

    )

    select * from mas

    CROSS APPLY

    (

    SELECT Value from RealtimeData sub

    where sub.Time = mas.Time

    ) as sub

    This question was not originally...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Missing numbers in a series

    You changed rather more than that!

    "Forgot" must remember that one. Funny.

    Not much. Basically, concept was of tally table. I implemented with the memory table, which was supposed to...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Insert data monthly into table from History Table

    For 2000 rows a day? 1 row every 43 seconds?????

    How's that ever gonna slow down a server and require an elaborate solution.

    You are right. But it is always to have...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Best solution to implement reporting out of a database

    if you are going for mirroring, this article might help you;

    http://technet.microsoft.com/en-us/library/ms175511.aspx

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Help me to write a query

    Solution according to me is...

    ;With wcte as (

    Select vTime,vValue,Row_Number() over (partition by Convert(DateTime,Convert(varchar(10),vTime,110)) order by vTime Desc) rno

    from @vTable

    )Select vTime,vValue from wcte where rno = 1

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Help me to write a query

    The question was;

    I need to write a SQL-Server query but I don't know how to solve. I have a table RealtimeData with data:

    Time ...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Deleting records with foreign keys

    In SSMS, expand table B and go to keys. Right-Click FK and select modify. Under Table Designer, expand INSERT And UPDATE Specific, Unde Delete Rule Select Cascade. Then Save. Repeat...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Deleting records with foreign keys

    While defining relationships, there is an option of "Delete Rule". You can set from there.

    Considering Table A as Parent and Table B and Table C are chile tables with Foreign...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Deleting records with foreign keys

    Why not to use cascade?

    By using Cascade, If you delete from Table A, Record(s) from Table B and Table C will bve automatically deleted.

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Help me to write a query

    No question, No answer. I think that was OP's first post.

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Best Invoicing Practices

    How are you recording the data on which you will generate the invoice. For example, an inventory invoice will definitely be based upon the Order and Order detail table. What...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Best solution to implement reporting out of a database

    It is better to go for Mirroring if you intend for the the same database structure to be used as of OLTP database.

    I would suggest that if you are thinking...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Insert data monthly into table from History Table

    You can also use Triggers for parallel insertion but it can slow down the Insert / update process. Using Service Broker can be helpful in this regard. Just initialize Service...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Insert data monthly into table from History Table

    My suggestion is that it will be better to keep the Month End tables in De-Normalized manner.

    I assume that you will be producing reports from this data or use...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • RE: Missing numbers in a series

    Sorry. forgot to replace the table names in the cte.

    DECLARE @MissingNumbers TABLE (N INT)

    Declare @vMax int

    INSERT INTO @MissingNumbers

    VALUES (19),(20)

    Set @vMax = (Select MAX(N) from @MissingNumbers)

    ;with wcte as (

    Select Top(@vMax) ROW_NUMBER()...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

Viewing 15 posts - 121 through 135 (of 444 total)