Viewing 15 posts - 2,206 through 2,220 (of 4,080 total)
We got another procedural junkie here. I have to go. Somebody please help me turn him from the dark side.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 15, 2009 at 3:05 pm
Jordon, look at how I used the @InsertTime variable in the insert.
The stuff you want to keep constant, variables are just fine.
I gotta run. I'm gonna call up...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 15, 2009 at 3:04 pm
You're still thinking procedurally... do the INSERT as a set.
declare @InsertTimeStamp datetime
set @InsertTimeStamp = getdate() -- because we don't want this to change
INSERT INTO dbo.SomeTable (UnitID,AcqCost,AcqDate,AssetDesc,InsertTimeStamp)
SELECT UNITID,...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 15, 2009 at 2:49 pm
Jordan, you are thinking procedurally here too.
SQL stores values. Don't worry about formatting until you DISPLAY those values.
Check this out:
declare @sample int
set @sample = 123
...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 15, 2009 at 2:32 pm
Welcome Newbie !! 🙂
I will counsel you to turn away from the dark side of procedural thinking and embrace the set-based truth.
...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 15, 2009 at 2:26 pm
Where's the loop? I see no WHILE statement before the BEGIN.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 15, 2009 at 2:18 pm
It depends. But I think that this would be a good question to put over on askSSC.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 15, 2009 at 1:31 pm
CASE
WHEN Convert(varchar(13),column1,112) < date1 THEN '1'
WHEN Convert(varchar(13),column1,112) < date2 THEN '2'
WHEN Convert(varchar(13),column1,112) < date3 THEN '3'
WHEN Convert(varchar(13),column1,112) IS NULL THEN '#N/A' ELSE '4'
END AS Grp
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 15, 2009 at 12:31 pm
Nah... he just mutated SOM into SOB... which I thoroughly enjoyed BTW.
Hope you're having a good vacation, Lynn.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 14, 2009 at 5:07 pm
Thanks for the explanation Shannon.
I'm glad you found your solution with PIVOT, but keep the crosstab (CASE) solution in mind if performance becomes an issue. ...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 14, 2009 at 4:43 pm
If your [dtTimeStamp] column is indexed, one suggestion would be to retain the [dtTimeStamp] in its original datetime format, and add another column ([GroupByDate]) in your view.
The...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 14, 2009 at 4:32 pm
What next?
"You'll have to get the rest of your question answered by someone else... they're about to close the casket, and nobody bothered to put extra batteries in here with...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 14, 2009 at 3:01 pm
I'm still not quite clear. Would you please do us a favor? Amend your sample data (which was very nicely scripted and we...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 14, 2009 at 2:56 pm
This will pick random rows from your table without regard to the sequence of the [NewAccountID] or [Random] columns.
;with cte as (select row_number() over(partition by accountid order by newid()) as...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 14, 2009 at 2:43 pm
Which galaxy?
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 14, 2009 at 2:37 pm
Viewing 15 posts - 2,206 through 2,220 (of 4,080 total)