Viewing 15 posts - 61 through 75 (of 162 total)
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...
December 12, 2013 at 5:02 pm
+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. ...
December 12, 2013 at 4:24 pm
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...
December 12, 2013 at 4:02 pm
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...
February 4, 2013 at 1:34 pm
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...
October 29, 2012 at 4:00 pm
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...
October 29, 2012 at 3:41 pm
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...
August 24, 2012 at 9:39 am
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)...
June 11, 2012 at 4:00 pm
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...
May 16, 2012 at 12:49 pm
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"...
May 16, 2012 at 6:39 am
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...
May 14, 2012 at 8:15 pm
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...
April 8, 2012 at 9:14 pm
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...
April 8, 2012 at 7:52 pm
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...
April 8, 2012 at 5:46 pm
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...
April 8, 2012 at 5:39 pm
Viewing 15 posts - 61 through 75 (of 162 total)