Viewing 15 posts - 196 through 210 (of 2,171 total)
Thank you.
I am ready to write an article about "DATETIME tricks". What now? Steve has to accept?
N 56°04'39.16"
E 12°55'05.25"
November 2, 2010 at 7:25 am
Yes, exactly as that. Except "mm" should be either "mi", "n" or "minute".
Using "mm" gives you 0 as result because "mm" denotes difference in months [boundary crossings].
"mi", "n" or...
N 56°04'39.16"
E 12°55'05.25"
November 2, 2010 at 4:46 am
You mean some kind of running total?
N 56°04'39.16"
E 12°55'05.25"
November 2, 2010 at 2:42 am
Seems like a lot of math calculations there...
See this http://weblogs.sqlteam.com/peterl/archive/2010/09/08/fast-easter-day-function.aspx
N 56°04'39.16"
E 12°55'05.25"
November 1, 2010 at 2:21 pm
DECLARE@Data XML ='<?xml version="1.0" encoding="UTF-8"?>
<xml>
<target>
<tag_pairs>
<tag_pair>
<name>addr1</name>
<values>
<value>20 Morris Ave</value>
</values>
</tag_pair>
<tag_pair><name>addr2</name><values><value></value></values></tag_pair>
<tag_pair><name>addr3</name><values><value></value></values></tag_pair>
<tag_pair><name>city</name><values><value>Wahroonga</value></values></tag_pair>
<tag_pair><name>state</name><values><value>New South Wales</value></values></tag_pair>
<tag_pair><name>zip</name><values><value>2076</value></values></tag_pair>
</tag_pairs>
</target>
</xml>'
SELECTn.value('../name[1]', 'VARCHAR(MAX)') AS Name,
n.value('value[1]', 'VARCHAR(MAX)') AS Value
FROM@Data.nodes('/xml/target/tag_pairs/tag_pair/values') AS v(n)
N 56°04'39.16"
E 12°55'05.25"
November 1, 2010 at 9:06 am
No, the table is NOT declared for each loop. You can confirm that at the final result.
However, I consider this bad practice and confusing to put the table declaration inside...
N 56°04'39.16"
E 12°55'05.25"
November 1, 2010 at 5:03 am
Some more datatime tricks...
DECLARE @FromDate DATETIME,
@ToDate DATETIME
SELECT@FromDate = DATEADD(DAY, DATEDIFF(DAY, 1, GETDATE()), '02:00'),
@ToDate = DATEADD(DAY, DATEDIFF(DAY, 1, GETDATE()), '03:00')
SELECT Database_Name,
Backup_Finish_Date,
...
N 56°04'39.16"
E 12°55'05.25"
November 1, 2010 at 2:56 am
WayneS is spot on. The table is declared not matter what AT the location in code where it is so all following code is referencing it correctly.
N 56°04'39.16"
E 12°55'05.25"
October 31, 2010 at 10:58 am
And just to be perfectly safe, use QUOTENAME
SET @sql = 'CREATE TABLE ' + QUOTENAME(@otherdb) + '.[dbo].[my_new_table]'
N 56°04'39.16"
E 12°55'05.25"
October 31, 2010 at 9:43 am
If you are using the parameter to insert into a datetime column, there is ABSOLUTELY no need to convert the date value.
Keep the date value in ISO YYYYMMDD date format...
N 56°04'39.16"
E 12°55'05.25"
October 31, 2010 at 9:39 am
I have a solution which yields this statistics
Table 'Worktable'. Scan count 1, logical reads 1, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob...
N 56°04'39.16"
E 12°55'05.25"
October 31, 2010 at 6:55 am
As I repeatedly have told you here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=152250
We don't know what your tables are named, what information is stored where and so on.
Also, we have no idea of foreign keys,...
N 56°04'39.16"
E 12°55'05.25"
October 31, 2010 at 3:37 am
I think Jeff means extending date ranges.
If you have three date ranges
20100101-20100630, 20100515-20100930 and 20100928-20101010,
the end result is 20100101-20101010.
N 56°04'39.16"
E 12°55'05.25"
October 31, 2010 at 12:05 am
Kevin Bullen (10/30/2010)
If the cursor iterates 1000 times, are 1000 instances of a table created, or is the same instance released and recreated.
Neither.
SQL Server is smart enough to move all...
N 56°04'39.16"
E 12°55'05.25"
October 30, 2010 at 11:56 pm
There will be only one copy of the table variable.
N 56°04'39.16"
E 12°55'05.25"
October 30, 2010 at 7:45 am
Viewing 15 posts - 196 through 210 (of 2,171 total)