Viewing 15 posts - 7,591 through 7,605 (of 8,416 total)
(Before we go on to set-based, let's tidy the RBAR a bit)
SET NOCOUNT ON
DECLARE @MyData TABLE(pk INT IDENTITY(1,1) PRIMARY KEY, id INT)
DECLARE @index INT
DECLARE @MyID INT
DECLARE @startTime DATETIME
DECLARE @endTime DATETIME
...
June 26, 2009 at 4:30 am
It stays in effect in nested procedures, as a simple test shows.
June 26, 2009 at 4:12 am
hi_abhay78 (6/25/2009)
select cast(@num as char)
Heh. Well unless you specifically need that integer as a fixed-length char(30)...
CONVERT(varchar(11), @num)
Paul
June 26, 2009 at 3:59 am
With your clarified description, the IDENTITY column would be closest in behaviour to an Oracle sequence.
ROW_NUMBER is great for individual set operations, but the next value in the row number...
June 26, 2009 at 3:37 am
Until a 'D3' expert comes along, my only suggestion would be to export the data from the source to a delimited file and bulk load that into SQL Server. ...
June 26, 2009 at 2:17 am
Peso (6/26/2009)
According to OP, he wants the numbers PRINTED, because they then are stored in the log file.
create database [04C87CAC-9AA8-4465-AC6E-921060A604FF];
go
alter database [04C87CAC-9AA8-4465-AC6E-921060A604FF] set recovery simple;
go
use [04C87CAC-9AA8-4465-AC6E-921060A604FF];
go
checkpoint
select * from fn_dblog(null, null)
print...
June 26, 2009 at 2:05 am
RBarryYoung (6/25/2009)
Alvin Ramard (6/25/2009)
Grant Fritchey (6/25/2009)
Hey, 2540F82F-05B8-4B01-A237-7A2A634E7D34. I was just talking about you with 0798AE98-F43B-4069-BE9F-5FFB9945D670. Good old 2540F82F, if you don't mind me being personal.
Are you sure you weren't talking...
June 25, 2009 at 3:20 pm
Carl Federl (6/25/2009)
Agree that the SQL for an after trigger appears simplier but try with a schema change and the after trigger.
Bizarre. So if we change the question the...
June 25, 2009 at 3:11 pm
DCPeterson (6/25/2009)
A clustered index is ALWAYS unique.
Was this reply prompted by my post?
If so, I think you might have missed what I was driving at 🙂
If you get a minute,...
June 25, 2009 at 3:03 pm
saidwarak01 (6/25/2009)
June 25, 2009 at 3:00 pm
jdurandt (6/25/2009)
Here is one that uses a cartesian product:
I love this one! Would use UNION ALL instead of UNION, but still...:-)
June 25, 2009 at 2:58 pm
Yeah I know what you mean - went through something similar with PCI-DSS (or whatever it was called).
Heh. You could always upgrade to 2008 Enterprise and use Transparent Database...
June 25, 2009 at 2:56 pm
Cool stuff Chris. Of course it leaves me wondered about the hash aggregate versus stream aggregate thing but hey.
So PIVOT can be slightly more efficient - if you can...
June 25, 2009 at 2:54 pm
Grant Fritchey (6/25/2009)
June 25, 2009 at 2:50 pm
...the AFTER trigger version of my code is simpler as expected:
ALTER TRIGGER trg_cnsmr_accnt_ai
ON dbo.cnsmr_accnt
AFTER INSERT
AS
BEGIN
IF@@ROWCOUNT = 0 RETURN;
SET NOCOUNT ON;
SET ROWCOUNT 0;
;WITHOrdered AS
(
SELECTcnsmr_id,
cnsmr_id + '-' + CONVERT(VARCHAR(10), 100 + ROW_NUMBER()...
June 25, 2009 at 3:45 am
Viewing 15 posts - 7,591 through 7,605 (of 8,416 total)