Viewing 15 posts - 1,126 through 1,140 (of 1,439 total)
with cte as (select *,Row_number() over(order by id) as rownumber,
count(*) over() as total from TableName)
select * from cte where rownumber between some integers
May 26, 2009 at 5:14 am
with cte as (
select CatID as RootCatID,CatID,NumOfProducts
from Hirarchy
union all
select c.RootCatID,h.CatID,h.NumOfProducts
from Hirarchy h
inner join cte c on c.CatID=h.ParentID
)
select RootCatID,sum(NumOfProducts) as NumOfProducts
from cte
group by RootCatID
May 26, 2009 at 4:02 am
Try this
declare @CatID int
--set @CatID=1;
set @CatID=5;
with cte as (
select CatID,NumOfProducts
from Hirarchy
where CatID=@CatID
union all
select h.CatID,h.NumOfProducts
from Hirarchy h
inner join cte c on c.CatID=h.ParentID
)
select sum(NumOfProducts) as NumOfProducts
from cte
May 26, 2009 at 3:21 am
select Col1,
case when len(Col1)>10 then Col1 end as Note
from T
May 21, 2009 at 2:31 pm
For the case where @var is an int, change
DTS:Property[@var]
to
DTS:Property[sql:variable("@var")]
May 21, 2009 at 2:07 am
Use ROUND
declare @MinValue decimal(10,5)
declare @MaxValue decimal(10,5)
declare @DecimalPlaces int
set @MinValue = 0.8230
set @MaxValue = 100.8811
--set @DecimalPlaces = 0
--set @DecimalPlaces = 1
set @DecimalPlaces = 2
select round(@MinValue,@DecimalPlaces,1)
select round(@MaxValue,@DecimalPlaces,1)
May 20, 2009 at 7:27 am
Try this, no extra TEXT elements
declare @xml as xml
set @xml = '
Somevalue1
somevalue2
somevalue3
'
DECLARE @language VARCHAR(4)
SET @language = '1023'
SELECT r.value('.','varchar(100)') AS Value
FROM @xml.nodes('/TRANSLATIONS/TRANSLATION[@language=sql:variable("@language")]')...
May 18, 2009 at 6:57 am
No need for dynamic SQL
DECLARE @language VARCHAR(4)
SET @language = '1023'
SELECT r.value('.','varchar(100)') AS Value
FROM @xml.nodes('/TRANSLATIONS/TRANSLATION[@language=sql:variable("@language")]/TEXT') AS x(r)
Also the XML isn't valid, the attributes are missing double quotes
May 18, 2009 at 4:11 am
Missing a '+7' ??
i.e.
SELECT charindex(' ',@string,charindex('view = ',@string)+7)- charindex('view = ',@string)
should be
SELECT charindex(' ',@string,charindex('view = ',@string)+7)- (charindex('view = ',@string)+7)
May 13, 2009 at 6:55 am
It will sort by the Employees name only within a level of the hierarchy. If you have a specific sorting requirement can you post it?
May 13, 2009 at 5:12 am
Can you supply some sample data? This appears to work
declare @General_Info table(first_name varchar(10))
insert into @General_Info(first_name)
select 'o_corner' union all
select 'other' union all
select 'x'
select * from @General_Info where first_name like 'o!_%' escape...
May 13, 2009 at 4:48 am
Use 'escape'
select * from General_Info where first_name like 'o!_%' escape '!'
May 13, 2009 at 4:38 am
ta.bu.shi.da.yu (5/13/2009)
Atif Sheikh (5/12/2009)
Hey... I tried that. Doesn't work if F reports to B.
To Who...?
Er... sorry. Got that badly wrong. Doesn't work if B reports to F.
So who...
May 13, 2009 at 3:58 am
See if this helps
CREATE TABLE #Employees(Employee CHAR(1) NOT NULL PRIMARY KEY, ReportsTo CHAR(1))
INSERT INTO #Employees(Employee, ReportsTo)
SELECT 'A',NULL UNION ALL
SELECT 'B','A' UNION ALL
SELECT 'C','A' UNION ALL
SELECT 'D','C' UNION...
May 12, 2009 at 6:33 am
RBarryYoung (5/11/2009)
Paul White (5/10/2009)
It's a very fast method - the only disappointment for me was that it is limited to processing text files. Text file bulk import is fast...
May 11, 2009 at 8:10 am
Viewing 15 posts - 1,126 through 1,140 (of 1,439 total)