Forum Replies Created

Viewing 15 posts - 106 through 120 (of 136 total)

  • RE: Updating a Table Variable with a From Clause

    Yes. Although actually, what it actually does is calculate the from/where clause first, and then matches the table in your update clause with one of them.

    With multiple references to the...

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

  • RE: Is there another way for this??

    Ugh. Yeah, ok... If you have a combination of normal spaces and M spaces throughout the string that you need to preserve, then you will have to play around a...

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

  • RE: Updating a Table Variable with a From Clause

    I agree that it seems wrong. And that other RDBMSs don't do it that way. Frequently I get frustrated at things in MS-SQL that seem wrong, given my Oracle background....

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

  • RE: Is there another way for this??

    Yup. Which is why you might want to push it through the replace function and then use rtrim, and maybe after that even push it back through a replace function,...

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

  • RE: Is there another way for this??

    Ok. So maybe pump the string through a replace() function first, so that it is a normal space?

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

  • RE: Is there another way for this??

    Have you seen: http://msdn.microsoft.com/library/en-us/tsqlref/ts_ra-rz_6xm5.asp?frame=true ?

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

  • RE: Is there another way for this??

    So... you're wanting an rtrim function?

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

  • RE: TOP 3 Kinda?

    Sorry - small typo. The 'else' statement in there makes the function invalid. If you remove it, then it's fine. Better still, surround 'return(1)' in 'begin' and 'end'.

    Here's an example...

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

  • RE: TOP 3 Kinda?

    I'm sure you can come up with a solution that doesn't use cursors.

    If you make a UDF that looks to see if a row is in the top 3 for...

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

  • RE: Updating a Table Variable with a From Clause

    If you use a from clause in an update statement, you should include the table you're updating. Try:

    update @tablevar set col1 = stock.description

    from @tablevar t join stock s on t.stockid...

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

  • RE: TSQL Short Circuiting

    Use a 'case' statement. That will stop the rest being executed. I've used '1=1' and '1=0' for the true and false scenarios. Check the logic of course... I didn't really...

    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

    Don't specify the page value in the query, just make sure that it matches from record to record.

    My version only returned one record for each 'triple', but returned three times...

    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

    Ignoring the (all valid) points about where queries should be written - you really should consider a user_defined function for it. If you want, you can make a view that...

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

  • RE: INSERT of consecutive numbers

    I'm very much in favour of having a 'numbers' table. You can easily have a 'topup' function if you think you might need to use a bigger number than what...

    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

    Sergiy,

    But he's asking about a 'select trigger', not insert/update/delete.

    So the concept of a trigger doesn't work.

    Rob

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

Viewing 15 posts - 106 through 120 (of 136 total)