Forum Replies Created

Viewing 15 posts - 61 through 75 (of 162 total)

  • RE: Aggregate data based on 1 hour intervals

    You could adjust the actual time by 30 minutes so that values that used to fall in to the 6:30-7:30 range now fall into the 6:00-7:00 range, then group by...

  • RE: SQL Thousand separator with round

    +1 for Sean; yes, formatting would better be done in the outputting program. If you have to do it in SQL, here is one option for your consideration. ...

  • RE: Insert dates into table in the giving range.

    If you don't want to create a Tally table, you can use sys.columns instead and create a tally number in memory. According to my research, this is actually faster...

  • RE: Create and Populate a Date Dimension Table

    Thank you for the informative script.

    I noticed that many of the fields are defined as SMALLINT, even those that would never go over a TINYINT value. These include DAY_OF_WEEK...

  • RE: Is there an accurate script for datediff format in years:months:days?

    Here is the code in Function format:

    SETANSI_NULLS ON

    SETANSI_PADDING ON

    IFOBJECTPROPERTY(OBJECT_ID('YMDDiff'), 'IsInlineFunction') IS NOT NULL

    DROP

    FUNCTIONYMDDiff

    GO

    CREATE

    FUNCTION dbo.YMDDiff

    (--<parameters>

    @StartDateDATETIME,--<param description="The starting date to use to calculate YMDDiff." />

    @EndDateDATETIME--<param description="The ending date to use to calculate...

  • RE: Is there an accurate script for datediff format in years:months:days?

    Since we are throwing hats in rings, here is what I would use:

    DECLARE@StartDateDATETIME = '19800510',

    @EndDateDATETIME = GETDATE()

    ;WITHYearDiff

    AS(SELECTDATEDIFF(YEAR, @StartDate, @EndDate) AS YearCount),

    MonthDiff

    AS(

    SELECTYearCount,

    DATEADD(YEAR, YearCount, @StartDate) AS YearBase,

    DATEDIFF(MONTH, DATEADD(YEAR, YearCount, @StartDate), @EndDate) AS...

  • RE: Get dependant Objects

    Try this. It refreshes the data in sysdepends. I don't guarantee that all necessary objects are covered, just the ones I was using when I wrote this.

    Yes, I...

  • RE: how to make Hierarchy Node level using this 2 tables?

    This solution is based on the Microsoft article: http://blog.crowe.co.nz/archive/2007/09/06/Microsoft-SQL-Server-2005---CTE-Example-of-a-simple.aspx

    Here is the revised DDL to set up the scenario:

    CREATE TABLE [dbo].[tblMembers](

    [MemberID] [int] IDENTITY(1,1) NOT NULL,

    [Name] [varchar](30) NULL

    )

    CREATE TABLE [dbo].[tblMembersRelation](

    [MembersRelationID] [int] IDENTITY(1,1)...

  • RE: using dynamic Sql with views

    Tom: You did not answer any of the questions that were asked. It would be helpful to have those answers to be able to more effectively help you.

    The basic...

  • RE: using dynamic Sql with views

    My answer assumed that there were three databases on the server ("RetailDev", "RetailQA", and "Retail"), and that each was a self-contained database, containing both an "Employee" table and a "MyView"...

  • RE: using dynamic Sql with views

    I would expect the view to be "SELECT * FROM dbo.Employees", without the database prefix. When connecting to the Retail or RetailDev database, the correct table will always be...

  • RE: Strange Tables In TempDB

    Lynn Pettis (4/8/2012)


    Multiple table joins, sorting are two activities that may create work tables in tempdb.

    Are those tables named similarly to what I have described above? Do those tables...

  • RE: Strange Tables In TempDB

    Perhaps I need to rephrase the question. What can create a table in the TempDB other than "CREATE TABLE #MyTempTable"?

    When I explicitly create a temp table, the table...

  • RE: Merge OPEN QUERY - Need to Insert CurrentDateTime

    The "GETDATE()" or "CURRENT_TIMESTAMP" will give you the same value for every row in a single statement. As long as your MERGE statement is a single statement, all records...

  • RE: OUTPUT CLAUSE - MERGE STATEMENT

    The OUTPUT clause can get values from the tables used in the queries with the exception of the INSERT statement; INSERTED and DELETED can be used, but the base...

Viewing 15 posts - 61 through 75 (of 162 total)