Forum Replies Created

Viewing 15 posts - 121 through 135 (of 136 total)

  • RE: SQL help on selecting records based on content and their neighbors content

    Hariharan,

    He doesn't say he wants the page number. Couldn't it be that the words go across two different pages?

    Of course, it depends on the actual context of the query.

    Your...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: trigger on view

    Using a stored procedure doesn't stop people from having access to the table as well though. Although, in SQL2005 you can tell the stored procedure to execute to impersonate an...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: SQL help on selecting records based on content and their neighbors content

    If you can't assume that wsequence is going to be x, x+1, x+2 in the case you want, then you might have to use a rownumber field on the table....

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: Counting a consecutive condition

    If you store the 'met' field for each day, then could you rephrase what you're looking for as:

    "Find an employee where there doesn't exist a 'not met' row between any...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: Return every nth record from resultset

    In SQL2005 with 'rownumber' introduced, you'll be able to do it without even thinking.

    However, in SQL2000 you would need to make a rownumber function for yourself.

    Look at http://support.microsoft.com/default.aspx?scid=KB;EN-US;q186133, and see...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: DateTime format to mmmdd format

    Then you've missed a space from what I wrote. Here it is with * instead of space.

    Replace(Replace(Convert(Char(6),@thedate,109),'**','0'),'*','')

    The concept is that you need to find the scenario where there are 2...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: DateTime format to mmmdd format

    Try this:

    declare @thedate datetime

    set @thedate = '4/25/05'

    --set @thedate = getdate()

    --set @thedate = '20050425'

    --set @thedate = '20050401'

    --set @thedate = '1-Apr-2005'

    Select replace(Replace(Convert(Char(6),@thedate,109),' ','0'),' ','')

    This is using a similar scenario, but first...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: tsql

    As suggested earlier, try doing the whole thing in a stored procedure, rather than calling the stored procedure 12 times. Then you can easily track what is happening to your...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: dynamic cursor in T-sql

    Remove the space in

    set @sql=('declare my_cur cursor for select ID, date from dbo. ' +@TABLENAME)

    set @sql=('declare my_cur cursor for select ID, date from...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: Combine like rows problem

    > I do need to keep the loan type as is because that is what we use for the report.

    Yes, but if you want count how many loans there are...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: DateTime format to mmmdd format

    Wow... when I need to pad in SQL, I just use the 'right' function.

    SUBSTRING( DATENAME(month, '01/01/2005'), 1, 3) + right('0' + DATENAME( day, '01/01/2005'),2)

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: dynamic cursor in T-sql

    I think you're mistaken here, Chris. If you create a cursor in an exec() statement, you can access it afterwards. Very handy thing, although I'm not sure it's actually by...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: Combine like rows problem

    You can probably get around it by doing "count(distinct B.Loan_Nbr)" instead of "count(B.loan_type)"

    Does this help?

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: Sorting by Date

    Or if you are needing to group by, etc... ie, you can only order by the field that's in your select query, then convert it back to a datetime field!...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

  • RE: dynamic cursor in T-sql

    A few things...

    You have an extra comma in the line:

    set @sql=('declare my_cur cursor for select , ID , date from dbo. ' +@TABLENAME)

    Try:

    set @sql=('declare my_cur...

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

Viewing 15 posts - 121 through 135 (of 136 total)