Viewing 15 posts - 271 through 285 (of 476 total)
Hi
I think this covers what you want to do. I suspect the performance will be poor.
WITH groupit AS (
-- Group up the Depts on data
SELECT CID, CDate, Dept,
ROW_NUMBER() OVER...
September 22, 2013 at 3:35 pm
Andreas P. Williams (9/20/2013)
Your method only works if the number of rows is a multiple of 5. Try and remove the ('J',1) and your bottom 20 per cent has...
September 20, 2013 at 4:22 pm
Hi you could also use NTILE.
As an example
WITH sampledata AS (
SELECT *, NTILE(5) OVER (ORDER BY Numbers DESC) N
FROM (VALUES
('A',134)
,('B',122)
,('C',88)
,('D',82)
,('E',33)
,('F',22)
,('G',18)
,('H',4)
,('I',1)
,('J',1)
) SD(Book,Numbers)
)
SELECT Book, Numbers,
CASE WHEN N = 1 THEN...
September 19, 2013 at 3:30 pm
dwain.c (9/18/2013)
mickyT (9/18/2013)
dwain.c (9/18/2013)
WITH SampleData (MyStr) AS (
SELECT 'Ørstedsvej 7B' UNION ALL
SELECT 'Volvo 25D' UNION ALL
SELECT '104ND Nokia'
)
SELECT MyStr
...
September 18, 2013 at 8:28 pm
dwain.c (9/18/2013)
WITH SampleData (MyStr) AS (
SELECT 'Ørstedsvej 7B' UNION ALL
SELECT 'Volvo 25D' UNION ALL
SELECT '104ND Nokia'
)
SELECT MyStr
...
September 18, 2013 at 8:06 pm
If you only have a single replacement like in your example then this should do the trick
SELECT STUFF(val,PATINDEX('%[0-9][a-z]%',val) + 1,0,' ')
FROM (VALUES
('Ørstedsvej 7B')
,('Volvo 25D')
,('104ND Nokia')
) SD(VAL)
If you have more than...
September 18, 2013 at 1:59 pm
Are those geometry columns in your query? If so you will not be able to include them in group by clause.
As Sean said some DDL and sample...
September 17, 2013 at 2:34 pm
Hi Nick
You could try the following. It makes use of PARSENAME and Jeff Modens DelimitedSplit8K function that can be found here[/url]
declare @line varchar(8000) = 'HEADER*Company.A*Company.B*5001*8/22/2009^CATEGORY*Parts*PRT^LINE*PartA*11^LINE*PartF*5^LINE*PartG*37^CATEGORY*Supplies*SUP^LINE*SupplyK*1^LINE*SupplyY*88^LINE*SupplyG*72^CATEGORY*Materials*MTR^LINE*MaterialQ*202^';
select
-- Header components
replace(
parsename(
replace(replace(replace(
substring(@line,1,CHARINDEX('^',@line)-1) --...
September 16, 2013 at 3:12 pm
Ditto on Dwain's comment, not a good idea.
You may cause yourself more issues down the line following this particular plan. For example are there any current queries...
September 15, 2013 at 8:54 pm
I always try to put the table I am updating as first in the FROM clause and use the alias as the UPDATE target.
UPDATE DC
SET DocType = SUBSTRING(STG.CurrDocNumber,1,1)
FROM DIM.DocControlProfile AS...
September 13, 2013 at 3:37 pm
Koen Verbeeck (9/11/2013)
ChrisM@Work (9/11/2013)
Hany Helmy (9/11/2013)
Hope one of them will post a reply explaining how...
September 11, 2013 at 1:20 pm
Either or will work, the difference being that STIntersects will also work on 2008 as well where STContains will not.
There could also be an arguement for using STWithin
declare @container geography...
September 11, 2013 at 1:10 pm
Hi
You can do a query like the following
DECLARE @pointgeo GEOGRAPHY = Geography::STGeomFromText('POINT (-122.56153600 45.603118166)', 4326)
SELECT c.Name
FROM Country c
WHERE c.Shape.STIntersects(@pointgeo) = 1
Just make sure that you SRIDs match.
Here's a link...
September 10, 2013 at 7:12 pm
Hi
Given that your points are likely to be fairly squarely placed an average of them will probably give you pretty good an consistent results
Probably the best method would be...
September 10, 2013 at 6:56 pm
Another option is
SELECT PATINDEX('%[^ ]%',@s) - 1
Not sure if it'll be any quicker, but you could add in tabs into the pattern as well
September 9, 2013 at 7:04 pm
Viewing 15 posts - 271 through 285 (of 476 total)