Reputation
2,130
Top tag
Next privilege 2,500 Rep.
Create tag synonyms
Badges
7 21
Newest
 Yearling
Impact
~99k people reached

1h
comment Need some assistance on MySQL Sub query
You could also correlate the subquery with the main query by changing its condition to WHERE call_type=d.call_type. Not sure if that would have any implications on performance, but at least you would avoid the possible mistake of changing the argument ('SALES') in one place and forgetting to do that in another.
1h
revised Need some assistance on MySQL Sub query
added line breaks to a code snippet for readability
18h
answered Optimize a SQL query
21h
comment Are junction tables a good practice?
@Namphibian: You mean even if I'm retrieving only the indexed columns from the table, MySQL will still have to touch the table? Is that how non-clustered indices work in MySQL?
21h
comment select row where a couple of column values is different
This assumes that all combinations of (ip, created_by) are unique, which might not be the case.
1d
revised Creating a stored procedure and adding date manually to filename
corrected the procedure name, fixed a typo
1d
answered Creating a stored procedure and adding date manually to filename
1d
answered How to only update if nothing has changed? I need to validate several things before I insert
Jul
3
comment Trigger/Event that fires when a Transaction finishes
It's not too late to update your question to make things clearer. Does the service that does the updates "know" when is the end of the transaction? Do you have control over the service and can you make changes to it? If I understand the situation correctly, it looks like using SET CONTEXT_INFO/CONTEXT_INFO() could be of help here.
Jul
2
revised connecting to a database via tsql on mac 10.10.4
the "t-sql" tag has to do with the Transact-SQL language whereas the "tsql" in this question seems to be a tool to connect to a database server
Jun
30
comment vtiger: can't login with newly created user
This might or might not turn out a question more appropriate here but in either event you shouldn't cross-post. You've already asked your question on Stack Overflow and at this time one person has voted to migrate it over here. If more people agree and vote likewise, your SO question will be moved over here, so there's no need to post it again (and cross-posting is actually a frowned-upon practice – just so you know).
Jun
26
comment Some records are missing while selecting from table
In this particular case a CTE is no more than a syntactic sugar. You could easily use a normal subselect instead of it and thereby avoid relying on the OP's using a 2005+ version. Just saying.
Jun
25
comment Setting variables in SQLCMD mode
I guess the important part here is that you have to have separate batches to 1) generate the SETVAR file, 2) execute it to initialise the script variable, and, finally, 3) use the script variable.
Jun
23
answered Use 'default value' in table when NULL
Jun
17
comment SQLcmd error 'Failed to initialize sqlcmd library with error number -2147467259'
Where (in which database) does the IndexOptimize stored procedure reside? You should remember that since sp_send_dbmail is in msdb, the query you supply to it as a parameter will be executed in the context of msdb. So, your query will probably need either to USE anotherdatabase (the one that contains IndexOptimize) before calling the procedure or to qualify the procedure name with the database name (as in 'anotherdatabase.dbo.IndexOptimize ''MyDB''').
Jun
16
comment Retrieving a record for the last date received and returning the value of another column in that row
Other than that, your question seems a classic example of the greatest-n-per-group problem.
Jun
16
comment Retrieving a record for the last date received and returning the value of another column in that row
Also, you haven't qualified the New_ReadingValue column with a table alias. Does it come from AccountExtensionBase or from New_meterreadingextensionBase?
Jun
16
comment Retrieving a record for the last date received and returning the value of another column in that row
This is not a suggestion of a solution, just a clarification: isn't your query supposed to have a GROUP BY?
Jun
15
comment Query trans log or tempdb?
Just to clarify, do you really mean adding OUTPUT COUNT(inserted.*) to an UPDATE statement? I never tried using COUNT in an OUTPUT clause before but I've just tried it and received Msg 158, Level 15, State 1, Line 8 An aggregate may not appear in the OUTPUT clause.
Jun
11
comment Wrong results from joining two CTEs
If you expected to get all rows from CTE1 plus matches from CTE2, then you should probably perform a LEFT OUTER JOIN rather than an INNER JOIN (between the CTEs).