Viewing 15 posts - 1,276 through 1,290 (of 1,438 total)
WITH CTE AS(
SELECT C1,C2,C3,C4,
ROW_NUMBER() OVER(PARTITION BY C1,C2 ORDER BY C3,C4) AS rn
FROM mytable)
SELECT C1,C2,C3,C4
FROM CTE
WHERE rn=1
October 9, 2008 at 8:15 am
select [Invoice No],
[Payment No],
[Payment Collected],
[Payment Date]
from TableB
where [Invoice No]...
October 7, 2008 at 2:22 am
This may help, using the Sql Server 2005 OUTPUT clause. This assumes name is unique in importperson
declare @t table(name varchar(100),person_id bigint)
insert into person(name)
output inserted.name,inserted.person_id into @t(name,person_id)
select name
from importperson
insert into SystemKeys(person_id,systemkey)
select...
October 6, 2008 at 4:57 am
The CTE "RootIDs" traverses up the hierarchy to gets the root IDs. These are then given to your CTE which traverses back down the hierarchy picking up the IDs you...
September 26, 2008 at 6:48 am
With RootIDs As (
Select Child_ID,Parent_ID
From #Site
Where Child_ID IN (3,10)
UNION ALL
Select a.Child_ID,a.Parent_ID
From #Site a
INNER JOIN RootIDs c ON a.Child_ID=c.Parent_ID
Where c.Child_ID<>c.Parent_ID),
MyCTE(Child_ID,Parent_ID)
As
(
Select
...
September 26, 2008 at 3:15 am
You should be able to do this using sp_getapplock / sp_releaseapplock. Check BOL for details.
September 24, 2008 at 9:42 am
WITH CTE AS (
SELECT DISTINCT ID,NAME,STATUS
FROM Test)
SELECT c.ID,c.NAME,c.STATUS,
(SELECT t.ADDRESS AS "text()" FROM Test t WHERE t.ID=c.ID ORDER BY t.ADDRESS FOR XML PATH(''))
FROM CTE...
September 22, 2008 at 3:47 am
Suggest you look at the OUTPUT clause
DECLARE @ids TABLE (Name VARCHAR(20), ID INT)
INSERT INTO Keywords (Name)
OUTPUT inserted.* INTO @ids
SELECT Name
FROM #NewKeywords
WHERE IDKeyword is null
SELECT * FROM @ids
September 18, 2008 at 5:26 am
DECLARE @s-2 VARCHAR(30)
SET @s-2='99202 10060 99000 A6402'
SELECT LEN(@S)-LEN(REPLACE(@S,' ','')) AS NumberOfSpaces
September 17, 2008 at 4:57 am
SELECT Customer_Id,
TestID
FROM dbo.Table_data
WHERE Customer_Id IN (
SELECT Customer_Id
FROM dbo.Table_data d
GROUP BY Customer_Id
HAVING COUNT(*)>1
AND COUNT(DISTINCT TestID) > 1)
September 16, 2008 at 7:02 am
with cte as (
select VehicleNo, TrackTime, row_number() over(partition by VehicleNo order by TrackTime) as rn
from mytable)
select a.VehicleNo,a.TrackTime
from CTE a
where not exists (select * from CTE b where b.VehicleNo=a.VehicleNo and b.rn=a.rn+1...
September 16, 2008 at 4:01 am
create table ranges(rmin int, rmax int)
insert into ranges(rmin , rmax )
select 0,20 union all
select 21,40 union all
select 41,60 union all
select 61,80 union all
select 81,100
select cast(rmin as varchar(10))+'-'+cast(rmax as varchar(10)) as...
September 12, 2008 at 8:23 am
As long as they both work correctly, it's up to you. You may want to check timings and execution plans in case there
are major differences. Also I think your version...
September 12, 2008 at 4:20 am
Viewing 15 posts - 1,276 through 1,290 (of 1,438 total)