Forum Replies Created

Viewing 15 posts - 3,286 through 3,300 (of 3,544 total)

  • RE: Check Columns Exist Before Select

    Unfortunately not. The use of GO splits queries into batches and a proc can only be one batch. BOL states that 'A table cannot be altered and then the new...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Left Outer Join

    Can u be more specific. With a left outer join the first result be be null if there is no data match! Can u post samples?

    I did post this on...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Record Selection

    Could use

    select distinct m.cola,m.colb from maintable m

    inner join othertable x on x.key = m.key

    or

    select m.cola,m.colb from maintable m

    inner join (select distinct key from othertable) x on x.key = m.key

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Check Columns Exist Before Select

    Insert GO between your statements,as in

    set nocount on

    if not exists (select column_name from information_schema.columns where column_name='RG_ENTRYDELETED' and table_name='REGISTRATION')

    alter table REGISTRATION add RG_ENTRYDELETED bit

    GO

    if not exists (select column_name from information_schema.columns...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: How to find the last of a date field

    Are you checking for the day (dd) or the whole date (yyyy-mm-dd) in your where clause.

    If you want to use the full date then try

    Declare @date datetime,@monthend DateTime

    Set @date='23 may...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: date problem with SQL 2000

    Beware that the date/time format is dependant on several things. NT/2000, version of IIS, whether a user is logged in or not, whether users are impersonated, the system default locale....

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: 'Spliting recordset'

    create table #zipsum (zip Varchar(5) null,CountPerZip int)

    insert into #zipsum values (12345, 5)

    insert into #zipsum values (23456, 4)

    insert into #zipsum values (23457, 2)

    insert into #zipsum values (11111, 1)

    insert into #zipsum values...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: 'Spliting recordset'

    create table tblTempZips2 (zip Varchar(15) null, id int primary key IDENTITY (1,1) not null )

    insert into tblTempZips2 (zip)

    select zip+' x '+cast(count(*) as varchar) from tblTempZips group by zip order by...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: 'Spliting recordset'

    Create another table from this one with distinct zip values and run the same query on the new table.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: 'Spliting recordset'

    declare @c int

    select @c = ceiling(count(*) / 3.0) from tblTempZips

    select a.zip as zip1,b.zip as zip2,c.zip as zip3

    from tblTempZips a

    left outer join tblTempZips b on b.id = (a.id + @c)

    left outer...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: 'Spliting recordset'

    Can u post table structure, small sample of data (non sensitive) and exactly what output you expect.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: 'Spliting recordset'

    If the ids are consecutive and want 3 cols then

    declare @c int,@i int

    select @i = count(*) from #t

    set @c = ceiling(@i / 3.0)

    select [id] as id1,

    (case when [id]+@c > @i...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Boolean or Integer for comparison

    Bear in mind on SQL7 you 'Cannot group by a bit column', don't know about 2000 though. You would have convert it or use case to do it.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: NT Groups and SQL Server Access Right

    Probably of no help as I have not done this and I am probably barking up someone else's tree but two things spring to mind.

    Are the NT Groups in the...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Testing text field for content

    Thanks for that Frank, will bear it in mind. We are still on SQL7 but now looking at future strategy for SQL.

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 15 posts - 3,286 through 3,300 (of 3,544 total)