|
Victor posted:Who knows how much intellisense will make it into SQL2008. It doesn't display the nullable status of fields, but SQL Prompt does a great job at doing what intellisense would do: http://www.red-gate.com/products/SQL_Prompt/index.htm
|
# ¿ Nov 2, 2007 14:51 |
|
|
# ¿ Apr 28, 2024 17:36 |
|
jwnin posted:(...) Are the database running on your server for your clients (IE they are using your server all the time) or is it just a backup you want to have access to ? Well, at first, updating thoses databases is gonna be a BITCH. "Hey joe, can you fix that stored procedure in the clients databases ? Sure boss, let me run that query in 1097 database, I'll be right back !" The risk of mistales is big too, because one or a few clients DB could end up different from the rest because of all that updating. comparing all theses database is also gonna be a bith, even with great tools. Also, you absolutely WON'T be able to query all clients at once, even if your boss thinks he's never gonna need it, he WILL. "Hey let's find out if somebody had that bug where the transactions were written all reversed..." Caching is gonna be ugly, if all clients use stored procedure X, they all gonna end up with a cached copy of the plan for that SP, even if it's exactly the same SP. That will mean fewer cached plans since you'll have so much identical plans cached (1000 copies of storedproc X's plan will be flushed when they try to run storedproc Y 1000 times too.
|
# ¿ Nov 9, 2007 12:55 |
|
chocojosh posted:Bringing the discussion back to SQL Server 2005 for a quick moment. In SQL Server management studio, just map CTRL-F1 to "sp_helptext". Go to Tools > Options > Environment > Keyboard. Then, all you have to do is higlight a storedproc / table / function, and press CTRL-F1. Edit:
|
# ¿ Nov 12, 2007 16:31 |
|
chocojosh posted:Great tip! I agree, that would be even cooler. I just end up copy-pasting what I need into a new window and modify from there. On thing that [b]SUCKS[b] with that, when doing that for a stored proc, each line is padded with some spaces (usually 3). It doesn't do anything wrong, but it's frustrating to press END and end up 3 spaces after the last character of that line. And if you do alter the stored proc from that script, the spaces are saved with the script and stay forever (until osmeone removes them).
|
# ¿ Nov 12, 2007 19:04 |
|
fletcher posted:What does the INNER do? What happens if you take it out? It JOINs tables for a SELECT, you don'T want to take it out, that'S your solution. It's like your "WHERE a.id = b.id" clause, that's a JOIN too, but that's the old way to join tables.
|
# ¿ Nov 21, 2007 12:59 |
|
Melraidin posted:(...) Calculating Running Totals, Subtotals and Grand Total in MSSQL Without a Cursor
|
# ¿ Dec 5, 2007 16:10 |
|
Melraidin posted:Thanks for the link, and this does do what I need. This article shows examples of solving this in the manner I would expect, but hadn't thought of. The major difference between this method (a sub-query for each row) and the MySQL method, at least from my understanding, is the MySQL method will only do the single query on the table, while the article's method will be doing Number of Rows + 1 queries on the table. If you want a GREAT book with a lot of complex problems solved, read Joe Celko's "SQL for Smarties - Advanced SQL Programming", it's an AWESOME book with lots of great solutions.
|
# ¿ Dec 5, 2007 16:39 |
|
foghorn posted:I've been banging my head against the wall over this one all night. You missed a period after $name : code:
|
# ¿ Dec 11, 2007 12:51 |
|
fletcher posted:PDO/MySQL question: Meet your new friend SQL_CALC_FOUND_ROWS !!! http://www.arraystudio.com/as-workshop/mysql-get-total-number-of-rows-when-using-limit.html
|
# ¿ Dec 21, 2007 17:05 |
|
ray2k posted:In sql server 2000, is there any way to check if a Text or varchar parameter is a valid xml document or fragment? Sql 2005 is not available for financial and political reasons. Basically, calling sp_xml_preparedocument with inputs that aren't valid xml causes an error that appears to be un-trappable. I'd like to have this SP indicate that condition by return code instead of bailing during execution. This should work: code:
|
# ¿ Jan 23, 2008 17:55 |
|
Im going out on a limb here, but I think you have to name the result of your inner SELECT if you do something with it (like your WHERE):code:
|
# ¿ Feb 8, 2008 03:55 |
|
GroceryBagHead posted:Hey. A very stupid question It should look like this: code:
Alex007 fucked around with this message at 22:24 on Feb 18, 2008 |
# ¿ Feb 18, 2008 22:14 |
|
GroceryBagHead posted:Thanks Alex, you're the best. I caught the OR thing as well Hey, no problem IsaacNewton's solution is great too, depending on the number or grassy knolls and/or dead unicorns, his solution may be faster (if there are fewer grassy knoll with dead unicorns in them).
|
# ¿ Feb 18, 2008 22:47 |
|
Even faster now, with a LEFT anti-JOIN the exclude knolls with dead unicorns in them:code:
|
# ¿ Feb 18, 2008 22:50 |
|
Victor posted:
You're gonna have to throw a DISTINCT there, otherwise hello grassy knolls multiplication !
|
# ¿ Feb 19, 2008 16:54 |
|
Victor posted:I don't know how to say this, other than no. Anti-joins like that don't need DISTINCT. You're right, I'm a dumbass for not thinking about it, sorry.
|
# ¿ Feb 19, 2008 18:24 |
|
nbv4 posted:That actually doesn't work because value1 is actually "SUM(another_value) AS value1" so it gives me this error: "#1247 - Reference 'value1' not supported (reference to group function)" You can't sort on grouped fileds, but you can do it (sort) in an outer select: code:
Alex007 fucked around with this message at 19:48 on Mar 25, 2008 |
# ¿ Mar 25, 2008 19:37 |
|
nbv4 posted:as you can see, it seems to think by "ORDER BY" I really meant "RANDOMIZE BY" If I order it by either total or simulator alone, it works as expected, but adding that plus sign screwes it all up. In the outer SELECT, convert NULLs to zeros, because NULL + anything = NULL. code:
|
# ¿ Mar 26, 2008 00:54 |
|
GroceryBagHead posted:Fun little problem. If I understand your problem, this is what I would do: code:
|
# ¿ Apr 3, 2008 15:08 |
|
GroceryBagHead posted:Sorry, I need to clarify: I need bees that are in flower_bees OR bee_flowers. code:
|
# ¿ Apr 3, 2008 15:24 |
|
Rakshas posted:I have two tables - the first one has a bunch of company information and user#s. The second table is strange, as it has a bunch of rows I need formatted as columns in the first table. I need one query to rule them all. I'd like to run the query and get something that resembles the Result Table. What platform is this gonna run on ? SQL 2005, SQL 2000, MySQL, Postgres ?
|
# ¿ Apr 8, 2008 14:09 |
|
Grigori Rasputin posted:What's the proper way to output a string from a stored procedure in Transact-SQL(MS SQLServer 2000)? I am finishing up an ancient project for someone and am not too familiar with it. Here's how to use an output parameter: code:
code:
Alex007 fucked around with this message at 21:48 on May 12, 2008 |
# ¿ May 12, 2008 21:45 |
|
Re-join with the same table, and use an alias:code:
|
# ¿ May 13, 2008 14:58 |
|
cLin posted:I am using phpMyAdmin. It has a Length/Value field right after you select the data type. It's the size of the field. It's clearer for char data types, it's the max number of chars you can fit in that field. For INT types, it's not the max value, it's the number of bytes the field has. Leave it empty for INT data types, mysql know the right size according to your INT type selection. Here's the table for int sizes: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
|
# ¿ May 13, 2008 19:49 |
|
MuppetPastor posted:Awesome. Thank you so much. Now I'm on to my next oddity. I use a parameter defaulted to null in a stored procedure for each field in the table. Then I use isnull() to test if the parameter was passed in. If so, I match it in my where clause, and if not, I just match the field to itself. Like this: The correct way to do it would be: code:
|
# ¿ May 13, 2008 20:09 |
|
MuppetPastor posted:
It's because NULL <> NULL (they are not equal). So when @field1 is NULL, SQL sees this code:
code:
|
# ¿ May 13, 2008 20:27 |
|
Civil posted:This should be really simple, but I'm just not getting it. Pretty new to mysql. The answer is not in the JOIN, it's in the GROUP BY: code:
|
# ¿ May 21, 2008 00:55 |
|
Civil posted:I do want records from TableA, even if they don't have a database match in TableB. My problem is that LEFT JOIN is giving me multiple returns on TableA when there are multiple matches on TableB. I only want the first match on TableB. This is why you need to GROUP BY, because JOIN *WILL* return all rows from table B when the join condition is met. Either you GROUP BY, just like I posted, of you join on a subquery to "prepare" table B, which would be slower and stupid. Here's what it would look like anyway: code:
code:
|
# ¿ May 21, 2008 01:09 |
|
Stephen posted:... Untested, but this is what you need I'm pretty sure code:
|
# ¿ May 21, 2008 21:36 |
|
Stephen posted:Hah, this is perfect, thanks. Just doing my job Stephen posted:I just assumed that since the IP address and Date values did not equal null, it should be returning the results anyways. You can't test NULL with = or != because NULL is unknown. If I show you two boxes and you do not know what's in them, you can't say the content is the same because they are BOTH unknown. = and != would BOTH return FALSE. code:
|
# ¿ May 21, 2008 21:47 |
|
Xae posted:Update the Column, set =0 where col is null Triggers ? For Default values ? God dammit this is a stupid idea. This is what you're looking for: code:
|
# ¿ May 27, 2008 23:58 |
|
Xae posted:What the gently caress do you think a default value is? Default values are better implemented using, well, default values, not triggers.
|
# ¿ May 28, 2008 01:11 |
|
chocojosh posted:At my work we have a C#/ASP.NET application that all use the same database on one development server. On my servers, the NTUSername isn't always filled, but I prefer to filter by SPID anyway. run sp_who2 to list the connections, decide which one you want to trace (you can see usernames and machine names here) and enter that SPID in the trace filter.
|
# ¿ Jun 4, 2008 15:58 |
|
chocojosh posted:sp_who2 returns *10* different results for my user. I think that it's making one different spid for each "New Query" tab I have opened in Sql server studio. Also, it seems that if I log out and log back into my application I have a different spid. sp_who2 takes a parameter, the login name, run it like this: EXEC sp_who2 'MYDOMAIN\MyUserName' (if you're using NT Auth)
|
# ¿ Jun 4, 2008 16:56 |
|
I'm probably overthinking the solution to this problem so I'm posting here to get some fresh ideas. I have a table: code:
I'm currently joining the table with itself to find matching ParamId's and Value's with different BatchId's, but validating that all params are there is getting complex and I've been running in circles for the past hour trying to figure this one out. Any pointers ?
|
# ¿ Sep 3, 2010 17:34 |
|
|
# ¿ Apr 28, 2024 17:36 |
|
Sprawl posted:What SQL you using? MSSQL Server 2000. EDIT: This is what I currently have, it seems to work, but for some reason I feel like I'm not doing it right at all. "Batch" is the header table for "BatchParams", which only indicates the batch type (must match) and "BatchTypeParams" is used to decided which parameters must match (UsedInUnicity) code:
Alex007 fucked around with this message at 18:06 on Sep 3, 2010 |
# ¿ Sep 3, 2010 17:53 |