Viewing 15 posts - 1,621 through 1,635 (of 2,007 total)
drew.allen (6/14/2011)
* You use this formula repeatedly in your query DATEADD(MINUTE,-@interval,DATEADD(MINUTE,N*@interval,@starttime))
I moved it into the CTE so that...
June 14, 2011 at 2:52 pm
Dan.Humphries (6/14/2011)
June 14, 2011 at 12:23 pm
m_cg (6/7/2011)
Jeff,Still not sure of the format, but gave it 2 ways. Does this work for you?
What Jeff's talking about is using a Tally table.
e.g.
DECLARE @date DATETIME, @number INT
SET @date...
June 8, 2011 at 9:05 am
Ordering is not guaranteed when you do not specify order by clause. So if you have no order by clause, then the query optimizer is free to return rows in...
June 6, 2011 at 9:25 am
drew.allen (6/3/2011)
skcadavre (6/3/2011)
June 4, 2011 at 11:14 am
drew.allen (6/2/2011)
Jnrstevej (6/2/2011)
Thanks for your reply, its not a homework question i'm in the process of designing a SSRS report and i need this section in the store procedure...
June 3, 2011 at 6:10 am
Like so: -
DECLARE @date DATETIME, @number INT
SET @date = '2011-06-06 00:00:00'
SET @number = 12
;WITH CTE AS (
SELECT 0 AS months
UNION ALL
SELECT months + 1
FROM CTE
WHERE months < @number-1)
SELECT DATEADD(MONTH,months,@date),
CONVERT(VARCHAR(10),DATEADD(MONTH,months,@date),...
June 2, 2011 at 9:36 am
Only need to post once 😉
http://www.sqlservercentral.com/Forums/Topic1118796-338-1.aspx
June 2, 2011 at 9:09 am
Is this a homework question? I ask because I answered something almost identical to this a couple of days ago (here). . .
One way would be to do it like...
June 2, 2011 at 9:07 am
GilaMonster (6/1/2011)
NText for a date? I wasn't aware dates could reach 2 billion unicode characters in length...
I guess that should've been my first comment - before complaining about presentation layer...
June 1, 2011 at 4:56 am
This is a presentation layer task, not a SQL task.
That being said, one way to do it in SQL would be: -
--Create test data
DECLARE @testdata AS TABLE (dates NTEXT)
INSERT INTO...
June 1, 2011 at 4:52 am
One simple way: -
DECLARE @date DATETIME, @number INT
SET @date = '2011-06-01 00:00:00'
SET @number = 6
;WITH CTE AS (
SELECT @number-1 AS months
UNION ALL
SELECT months - 1
FROM CTE
WHERE months > 0)
SELECT...
June 1, 2011 at 4:33 am
Whenever possible, I use set-based solutions. But it has occurred in the past where I simply couldn't think one.
For example, this is my answer to a question on this site...
May 27, 2011 at 8:13 am
Like this?
--First, lets build some ready consumable test data
DECLARE @TABLE AS TABLE(ID INT IDENTITY, CityName VARCHAR(20))
INSERT INTO @TABLE
SELECT 'Phnom Penh </Title>'
UNION ALL SELECT 'Siem Reap</Title>'
--Select from table
SELECT * FROM @TABLE
--Now...
May 25, 2011 at 4:25 am
Viewing 15 posts - 1,621 through 1,635 (of 2,007 total)