Forum Replies Created

Viewing 15 posts - 2,191 through 2,205 (of 3,543 total)

  • RE: SELECT INTO statement

    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...

  • RE: Max n Min in a series

    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...

  • RE: Max n Min in a series

    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...

  • RE: Max n Min in a series

    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....

  • RE: Joining tables from 2 separate servers

    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...

  • RE: Retrieving data from excel file

    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...

  • RE: determining whether a directory exists? xp_dirtree, xp_subdirs ?

    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...

  • RE: determining whether a directory exists? xp_dirtree, xp_subdirs ?

    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...

  • RE: need Help in select query

    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...

  • RE: Transferring information between one database and another

    Thank you Jesper, just reciprocating the favour

  • RE: need Help in select query

    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...

  • RE: Transferring information between one database and another

    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...

  • RE: need Help in select query

    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],...

  • RE: Hate cursors? Are you a genius query optimizer?

    Oooops!

    Missed that, glad someone noticed

  • RE: Question of the Day for 29 Aug 2005

    I wonder if you get overflow or page faults

    Only joking, lol

Viewing 15 posts - 2,191 through 2,205 (of 3,543 total)