Viewing 15 posts - 2,701 through 2,715 (of 3,957 total)
aaron.reese (9/27/2012)
September 27, 2012 at 5:54 am
There's actually a much easier way (using Jason's set up data):
SELECT i, targetNode=item
FROM @yourTable
CROSS APPLY dbo.DelimitedSplit8K(someStringField, '_')
WHERE itemnumber = 3
Again, credit to Jeff Moden for the DelimitedSplit8K function: http://www.sqlservercentral.com/articles/Tally+Table/72993/
He's the...
September 27, 2012 at 12:27 am
This may help.
DECLARE @T TABLE
(Col1 INT, Col2 INT, Col3 INT, Col4 INT
,Col5 INT, Col6 INT, Col7 INT, Col8 INT
...
September 27, 2012 at 12:14 am
laurie-789651 (9/26/2012)
Nested REPLACE is very efficient, so there will not be a faster way.
There's nearly always a faster way:
DECLARE @a AS VARCHAR(1000)
SET @A = 'This is <<FirstName>> <<LastName>> FROM <<PLACE>>,...
September 27, 2012 at 12:03 am
The "funky for xml stuff" is actually the standard way to concatenate strings off of multiple records. Sorry I don't have a link to point you to handy. ...
September 26, 2012 at 10:54 pm
Since you've indicated some flexibility in the route naming results, try this and see if it helps:
create table #Trips
(
ID int identity(1,1),
RouteID int,
Routename nvarchar(20),
Origin nvarchar(1),
Destination nvarchar(1)
)
insert into #Trips values (1,'ReturnTrip','A','B')
insert...
September 26, 2012 at 10:25 pm
elogen (9/26/2012)
There are possibilities I think that it may fail if a return route doesn't exactly retrace the same steps, especially if it is through different way points. That may...
September 26, 2012 at 9:33 pm
elogen (9/26/2012)
it seems to work beautifully!
I'm just going to play around with some other scenarios that I've found with the data I'm given.
It seems...
September 26, 2012 at 9:14 pm
CELKO (9/26/2012)
I have a datetime (your standard yyyy-mm-dd hh:mm:ss) column and a varchar column that holds an appt time that looks like this: 1030 or 0735. I need...
September 26, 2012 at 9:04 pm
Nice set up data Sean!
Using it, I'd like to offer a slightly less verbose solution:
SELECT *, WaitTime=DATEDIFF(minute
,CAST(check_in AS TIME)
,CAST(STUFF(appt_time, 3, 0, ':')...
September 26, 2012 at 8:29 pm
Since the two CTEs are virtually identical, here's another option that may be a little cleaner (put the second one into a temp table):
SELECT RouteName=Routename +
...
September 26, 2012 at 8:18 pm
aaron.reese (9/26/2012)
September 26, 2012 at 7:50 pm
Note that one other thought occurred to me. You could have another route that's identical to other routes except that the origin/final destination are different, such as this:
ID ...
September 26, 2012 at 7:47 pm
How about something like this?
DECLARE @StartDT DATETIME = '2011-04-01'
;WITH Dates AS (
SELECT TOP (1+DATEDIFF(day, @StartDT, DATEADD(day, -1, DATEADD(year, 1, @StartDT))))
...
September 26, 2012 at 7:29 pm
Try this. Same set up data as Aaron but different temp table name.
create table #Trips
(
ID int identity(1,1),
RouteID int,
Routename nvarchar(20),
Origin nvarchar(1),
Destination nvarchar(1)
)
insert into #Trips values (1,'ReturnTrip','A','B')
insert into #Trips values...
September 26, 2012 at 6:51 pm
Viewing 15 posts - 2,701 through 2,715 (of 3,957 total)