Viewing 15 posts - 1,066 through 1,080 (of 1,439 total)
If you are inside a stored procedure, function or trigger
object_name(@@procid)
August 7, 2009 at 11:27 am
Avoiding the parent axis as mentioned here may improve performance
http://msdn.microsoft.com/en-us/library/ms345118(SQL.90).aspx
SELECT Doc.value('NAME[1]', 'varchar(16)') AS [Name],
Doc.value('VALUE[1]', 'varchar(16)') AS [Value],
...
August 7, 2009 at 10:34 am
Another way
WITH CTE AS (
SELECT ID, NR, Txt, Val1,
ROW_NUMBER() OVER(PARTITION BY NR,Val1 ORDER BY ID) AS rn,
...
August 5, 2009 at 8:41 am
SELECT ename + CASE WHEN COUNT(*) OVER(PARTITION BY ename) > 1 THEN ' ' + ecode ELSE '' END
FROM emp
August 5, 2009 at 2:54 am
Jeff Moden (7/24/2009)
Mark (7/13/2009)
create function dbo.ConvertIp2Num(@ip nvarchar(15))
returns bigint
as
begin
return ((cast(parsename(@ip,4) as bigint)*256+
cast(parsename(@ip,3)...
July 24, 2009 at 9:11 am
Ken McKelvey (7/23/2009)
This may be a slightly simpler way to catch the gap in RangeId
;WITH CTE AS (
SELECT RangeId,
CountryCode,
...
July 23, 2009 at 11:20 am
There is one issue, but we only encountered it after further testing and in fairness my examples didn't highlight this potential scenario.
Mark's solution assumes that the RangeId values are in...
July 23, 2009 at 9:30 am
bmoynihan (7/23/2009)
Hi Mark,Your solution is fantastic ... really ingenius ... thank you.
I had read about using OVER, but would not have thought of your approach in a long, long time.
Thanks...
July 23, 2009 at 6:50 am
WITH CTE AS (
SELECT RangeId,
CountryCode,
CurrencyCode,
ROW_NUMBER() OVER(PARTITION BY CountryCode ORDER...
July 23, 2009 at 5:56 am
Ryan Keast (7/20/2009)
AGE =
-- Find difference in years and subtract 1 if date is before this years birthday
...
July 20, 2009 at 9:27 am
WITH CTE AS (
SELECT mobilenumber,activationdate,status,
ROW_NUMBER() OVER(PARTITION BY mobilenumber ORDER BY activationdate DESC) as rn)
SELECT mobilenumber,activationdate,statu
FROM CTE
WHERE rn=1
July 20, 2009 at 9:16 am
Michael Valentine Jones (7/20/2009)
declare @date_of_birth datetime
set @date_of_birth = '19770801'
select
...
July 20, 2009 at 9:03 am
Maybe this
select xData_1.value('
sum(for $x in /items/item
where $x/@year=2009 and $x/@month=6
return $x/@amount)','int')
from MyTable
July 20, 2009 at 7:59 am
This should get you started
SELECT District,School,
SUM(CASE WHEN Gender='M' THEN Count ELSE 0 END) AS MALES,
SUM(CASE WHEN...
July 20, 2009 at 7:21 am
Jonathan Kehayias (2/3/2009)
doobya (2/3/2009)
July 20, 2009 at 2:36 am
Viewing 15 posts - 1,066 through 1,080 (of 1,439 total)