Viewing 15 posts - 6,766 through 6,780 (of 8,416 total)
lmeinke (11/6/2009)
November 6, 2009 at 7:15 pm
Rob Fisk (11/6/2009)
Yes. Though I did not specifically mention so I was aiming to intimate that I was avoiding the dynamic where possible.
Yeah - I'm naturally anti-red-text too.
Rob Fisk (11/6/2009)
November 6, 2009 at 6:18 pm
Generally one would do this with triggers (though you have to be careful to handle UPDATEs and DELETEs on both tables gracefully too), though if you are happy to lose...
November 6, 2009 at 6:12 am
Cool. The other option would be dynamic SQL, but personally I like the UNION.
November 6, 2009 at 6:06 am
SQL Guy-482125 (11/4/2009)
Thanks, that's good solution, you moved insert ouside of transaction. This is what I needed.
You might like to change the ROLLBACK TRANSACTION to:
IF XACT_STATE() != 0 BEGIN ROLLBACK...
November 6, 2009 at 4:24 am
Adam Gojdas (11/5/2009)
Please be aware the ERROR_MESSAGE() function returns a nvarchar(4000). So you will run the risk of truncating some of the messages using the variable declared as varchar(100).
It's...
November 6, 2009 at 4:22 am
Allister Reid (11/6/2009)
Thought you guys might like this one: http://thedailywtf.com/Articles/Slightly-OverSQLd.aspx
Nice. Though personally I would have called the database to throw the exception π
November 6, 2009 at 4:16 am
...compare the plan for the example that does work (with the UNIONs) against the plan for this:
--
-- This also works
--
DECLARE @Choice INTEGER;
SET @Choice = 3;
IF ...
November 6, 2009 at 4:04 am
Hey Rob,
Check this out π
--
-- This doesn't work
--
DECLARE @Choice INTEGER;
SET @Choice = 3;
IF @Choice = 1
BEGIN
SELECT TOP (1) a = 1...
November 6, 2009 at 3:50 am
Luis,
Just a guess really, but:
SELECT OW.data,
LEFT(OW.docnome,3) + ' nΒΊ' + RIGHT('00000' + OW.intid, 5) as 'DocTesouraria',
...
November 6, 2009 at 3:28 am
Ian Scarlett (11/6/2009)
I still have a long way to go to catch you up ...in both number of posts and sheer depth of SQL Server knowledge
Hmm I'm not sure you're...
November 6, 2009 at 3:10 am
An alternative, mostly because I'm a bit bored:
SELECT ColA, ColB, colC
FROM (
SELECT ColA, ColB, colC,
...
November 6, 2009 at 3:09 am
Ian Scarlett (11/6/2009)
Not up to your usual bulletproof solutions Paul;-)INSERT dbo.SingleRowOnly (data) VALUES ('A'); -- Succeeds
insert enforcesinglerow (row_id) values(2)
INSERT dbo.SingleRowOnly (data) VALUES ('B'); -- Now it works
Yeah I...
November 6, 2009 at 2:12 am
November 6, 2009 at 2:11 am
Ok, just for fun, here's a complete implementation (I think!)
Minimal comments: half the fun is figuring out how it works π
This sample allows an empty table, until the first record...
November 6, 2009 at 1:54 am
Viewing 15 posts - 6,766 through 6,780 (of 8,416 total)