Viewing 15 posts - 2,191 through 2,205 (of 3,544 total)
SELECT b.Top_state, b.Tot_State, c.School_name, c.Tot_marks AS [Tot_School]
FROM (
SELECT TOP 5 a.Top_state, SUM(a.Tot_marks) AS [Tot_State]
FROM Tresult a
GROUP BY a.Top_state
ORDER BY SUM(a.Tot_marks) DESC) b
INNER JOIN Tresult c ON c.Top_state = b.Top_state
AND c.School_name...
Far away is close at hand in the images of elsewhere.
Anon.
September 16, 2005 at 8:00 am
As already mentioned, different table names and syntax error
you need something like this
set @sql = replace(@sql,' from ',' into ##mytemp from ') + '; SELECT * from ##mytemp'
And I presume...
Far away is close at hand in the images of elsewhere.
Anon.
September 16, 2005 at 7:12 am
First look at what costs the most in the plan
If you look at the plan for the first select query there are 3 table scans, which means that each row...
Far away is close at hand in the images of elsewhere.
Anon.
September 16, 2005 at 6:46 am
create table #temp (minval int, maxval int, series int)
insert into #temp
select a.value,b.value,count(*)
from [Table] a
cross join [Table] b
inner join [Table] c on c.value between a.value and b.value
where b.value > a.value
group...
Far away is close at hand in the images of elsewhere.
Anon.
September 16, 2005 at 3:05 am
select top 1 a.value,b.value,count(*)
from [Table] a
cross join [Table] b
inner join [Table] c on c.value between a.value and b.value
where b.value > a.value
group by a.value,b.value
having count(*) = b.value-a.value+1
order by count(*) desc
p.s....
Far away is close at hand in the images of elsewhere.
Anon.
September 15, 2005 at 8:36 am
if an error occurred and the linked server was not deleted.
Of course you could make the linked server permament, making sure you have the correct security set.
Alternatively, read OPENROWSET in...
Far away is close at hand in the images of elsewhere.
Anon.
September 15, 2005 at 7:15 am
SELECT * FROM
OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\temp\book1.xls;HDR=YES', [sheet1$])
Change to the path for the xls file and use HDR=NO if there are no headers in the file (in which case the...
Far away is close at hand in the images of elsewhere.
Anon.
September 14, 2005 at 7:20 am
In addition, thought I would look further into this. It is a shame that MS did not create xp_direxists and documented these Extended procedures. So, I wrote my own xp_direxists...
Far away is close at hand in the images of elsewhere.
Anon.
September 12, 2005 at 2:43 am
CREATE TABLE #temp (FileExists int, IsDirectory int, ParentDirExists int)
INSERT INTO #temp
EXEC master..xp_fileexist 'C:\windows'
IF EXISTS(SELECT IsDirectory FROM #temp WHERE IsDirectory=1)
PRINT 'windows exists'
ELSE
PRINT 'not exists'
DROP...
Far away is close at hand in the images of elsewhere.
Anon.
September 8, 2005 at 7:21 am
or
select t1.City, count(t2.place) as [no_of_events]
from (select distinct c.City from Test1 c) t1
left outer join Test2 t2 on t2.Place = t1.City
group by t1.City
order by t1.City
if all the cities need to be...
Far away is close at hand in the images of elsewhere.
Anon.
September 6, 2005 at 6:44 am
Thank you Jesper, just reciprocating the favour
![]()
Far away is close at hand in the images of elsewhere.
Anon.
September 6, 2005 at 6:41 am
Agree also, the nearest I came up with is
select t1.City, count(*) as [no_of_events]
from (select distinct c.City from Test1 c) t1
inner join Test2 t2 on t2.Place = t1.City
group by t1.City
order by...
Far away is close at hand in the images of elsewhere.
Anon.
September 6, 2005 at 6:37 am
Few observations, good practice
use ansi joins
update l
set l.rollStatus = t.rollStatus, l.Form = t.Form
from liveDB..tblstudent l
inner join testDB..tbl1student t on t.studentID = l.studentID
always declare column names instead of * where possible
use not...
Far away is close at hand in the images of elsewhere.
Anon.
September 6, 2005 at 6:26 am
I think it should be one of these two... maybe ![]()
select t1.city,
case when max(t3.no_of_games) is null then null else t1.[name] end as [name],...
Far away is close at hand in the images of elsewhere.
Anon.
September 5, 2005 at 11:23 am
Oooops! ![]()
Missed that, glad someone noticed ![]()
Far away is close at hand in the images of elsewhere.
Anon.
August 31, 2005 at 10:00 am
Viewing 15 posts - 2,191 through 2,205 (of 3,544 total)