Viewing 15 posts - 586 through 600 (of 2,007 total)
Not sure if this is any better, but here's one way: -
SELECT
a.id1, MAX(b.d1) AS description,
a.id2, MAX(b.d2) AS description,
a.id3, MAX(b.d3) AS description,
a.id4, MAX(b.d4) AS description
FROM Table1 a
CROSS APPLY (SELECT
...
July 25, 2012 at 6:41 am
ChrisM@Work (7/25/2012)
Phil Parkin (7/25/2012)
ChrisM@Work (7/25/2012)
Don't forget that TOP is meaningless without...
July 25, 2012 at 6:26 am
beeramgopi (7/25/2012)
(RowId INT, CustomerId INT, TransId INT, Pts INT)
INSERT INTO @CumCredit (Rowid, CustomerID, TransId, pts)
select 1,123,121,10
union
select 2,123,131,20
union
select 3,123,141,15
select * from @CumCredit
select a.*, (select sum(Pts) from @CumCredit where...
July 25, 2012 at 4:04 am
Jeff Moden (7/6/2012)
Cadavre (7/6/2012)
SELECT MAX(CASE WHEN RowNum % 3 = 0 THEN Column1 ELSE...
July 6, 2012 at 8:10 am
Jeff Moden (7/6/2012)
--===== Conditionally drop the test table to make reruns in SSMS easier.
...
July 6, 2012 at 6:55 am
David McKinney (7/6/2012)
Thanks....I was puzzled why you introduced underscores into the mix. Would [a-z0-9] not be more appropriate (more restrictive) e.g. wouldn't allow funny characters.
Yes, laziness from me 😉
Technically,...
July 6, 2012 at 4:55 am
Sure. How's this?
SELECT pk, pcode
FROM postcode
CROSS APPLY (SELECT REPLACE(pcode COLLATE Latin1_General_BIN2,' ','')) b(fixedPcode)
/*---------------------------------*UK Postcodes are arranged like this: -
SortingOfficeCode+Space+LocalCode
e.g. SK13 8LY or M1 1AA
The LocalCode is always 3 characters...
July 6, 2012 at 4:17 am
David McKinney (7/6/2012)
Cadavre (7/6/2012)[hrActually, this would probably be more accurate: -
SELECT pk, pcodeFROM postcode
CROSS APPLY (SELECT REPLACE(pcode COLLATE Latin1_General_BIN2,' ','')) b(fixedPcode)
WHERE fixedPcode LIKE '[A-Z][A-Z0-9][0-9][A-Z][A-Z]'
OR fixedPcode LIKE '[A-Z][A-Z0-9]_[0-9][A-Z][A-Z]'
OR fixedPcode LIKE '[A-Z][A-Z0-9]__[0-9][A-Z][A-Z]'
Depends...
July 6, 2012 at 3:52 am
zxxz (7/5/2012)
Sorry again, re-updating the original post. 🙂 I apologize in advance for any mistakes, but I don't think there are any.
Corrected your DDL: -
--===== If the test tables already...
July 6, 2012 at 3:17 am
David McKinney (7/6/2012)
consider also something like the following:x LIKE '[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]'
or x LIKE '[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]'
Actually, this would probably be more accurate: -
SELECT pk, pcode
FROM postcode
CROSS APPLY (SELECT REPLACE(pcode COLLATE Latin1_General_BIN2,' ',''))...
July 6, 2012 at 3:07 am
More information please!! 😀
To get the previous Sunday, you could do something like this: -
DECLARE @date AS DATETIME = '2012-07-05 00:00:00.000';
SELECT DATEADD(WEEK, DATEDIFF(WEEK, '2012-01-08', @date), '2012-01-08'); -- Previous Sunday,...
July 5, 2012 at 5:19 am
WHERE LEN(pcode) IN (6,7) AND CHARINDEX(' ',pcode) = 0
This is probably not a good way of determining validity of post codes though, there are a lot of rules (well, there...
July 5, 2012 at 5:05 am
You haven't really given enough information to answer your question.
Here's a random guess: -
WITH t1(N) AS (SELECT N FROM (VALUES(1),(1))a(N)), -- 2 Rows
t2(N) AS (SELECT 1 FROM t1 x, t1...
July 5, 2012 at 2:40 am
chaithu559 (7/4/2012)
Let me take 2 examples :
microsoft i am referring to : select * from emp ,dept where emp.deptno=dept.deptno
So, is there...
July 4, 2012 at 2:37 am
Viewing 15 posts - 586 through 600 (of 2,007 total)