Viewing 15 posts - 106 through 120 (of 136 total)
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
May 8, 2005 at 11:34 pm
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
May 8, 2005 at 11:19 pm
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
May 8, 2005 at 11:11 pm
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
May 8, 2005 at 10:21 pm
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
May 8, 2005 at 10:09 pm
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
May 8, 2005 at 9:30 pm
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
May 8, 2005 at 9:28 pm
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
May 8, 2005 at 9:24 pm
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
May 8, 2005 at 9:13 pm
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
May 8, 2005 at 9:04 pm
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
April 27, 2005 at 7:34 pm
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
April 27, 2005 at 7:23 pm
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
April 27, 2005 at 7:19 pm
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
April 27, 2005 at 1:42 am
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
April 27, 2005 at 1:15 am
Viewing 15 posts - 106 through 120 (of 136 total)