Viewing 15 posts - 5,626 through 5,640 (of 5,678 total)
LutzM (9/8/2010)
I usually try to avoid using DATEPART() at all due to the side effects of DATEPART(dw,) and ...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 8, 2010 at 3:04 pm
elayevskiy (9/7/2010)
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 8, 2010 at 3:00 pm
Example below:
declare @blah DATETIME
SET@blah = '2010-09-08 13:45:00.000'
print LEFT( datename(dw, @blah), 3) + ', '
+ left( datename( month, @blah), 3) + ' '
+ datename( dd, @blah) + ',...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 8, 2010 at 2:36 pm
LutzM (9/8/2010)
I would prefer a solution that would be able to benefit from an index on that date column, (snip)
Lutz, since when does a case statement in a returned column...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 8, 2010 at 2:19 pm
I don't have a way to turn those off, but all of your dynamic code should be used with sp_executesql using parameters to help protect against sql injection if you...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 8, 2010 at 2:14 pm
In Books Online (Help-Index), look up the CONVERT() function. It will give your your date time formatting options there.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 8, 2010 at 2:08 pm
Code snippet: Alter as needed
CASE WHEN DATEPART( hour, @myDate) between 7 and 13 /*(1:59PM and lower)*/ then 1 when DATEPART( hour, @myDate) between 14 and 23 then 2 else 3...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 8, 2010 at 2:01 pm
Please note the sample build code in the original post, where it shows that the first set of columns (for more then 8 fields) are in the most significant byte....
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 8, 2010 at 12:37 pm
Jeff Moden (9/8/2010)
IF ( (SUBSTRING(COLUMNS_UPDATED(),1,1)=power(2,(3-1))
+ power(2,(5-1)))
...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 8, 2010 at 10:19 am
I've never seen a situation where it didn't unless the clustered indexing was changed (since you don't have an order by) or there's something strange going on with the identity...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 7, 2010 at 5:19 pm
igngua (9/7/2010)
[IdContrato] [decimal](10, 0) NOT NULL,
[EiCanalId] [decimal](10, 0) NOT NULL,
[EiFechServ] [datetime] NOT NULL,
[EiFechMaq] [datetime] NOT NULL,
[EiFechCorr] [datetime] NOT NULL,
[EiValorFis] [decimal](25, 4) NOT NULL,
[EiValorNum] [decimal](25, 4) NOT...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 7, 2010 at 4:41 pm
Lowell (9/7/2010)
remember the UPDATE() function and the COLUMNS_UPDATED() function just returns whether the column was actually referenced in the insert/update statement, NOT whether the column changed it's value;
If I'd...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 7, 2010 at 4:09 pm
Msg 286, Level 16, State 1, Procedure TR_WHATEVER, Line 5
The logical tables INSERTED and DELETED cannot be updated.
Um, errr... dang, I'd have sworn I've done that before. I'm off...
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 7, 2010 at 3:53 pm
Jeff Moden (9/7/2010)
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 7, 2010 at 3:47 pm
I think you're looking for something like:
CREATE TRIGGER tr_test ON dbo.A FOR INSERT AS
UPDATE inserted
SET col1 = <value>
where col1 = 'm'
UPDATE inserted
SET col2 = <value2>
where col2 = 'n'
END
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 7, 2010 at 3:09 pm
Viewing 15 posts - 5,626 through 5,640 (of 5,678 total)