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

8h
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).
Jun
11
comment T-SQL - How to split (char separated) string into rows and columns
I haven't, sorry. I just happen to be aware of that disagreement. I think Jeff mentions some blog post or article on the SQL Server Central site that contains the original (or a link to it, not sure), but I didn't try to locate it as I'm not registered at SSC.
Jun
11
comment T-SQL - How to split (char separated) string into rows and columns
FYI, the original Moden function was not designed to work with NVARCHAR(max), and he may feel very strongly about people changing his code and still labelling it "(original) Jeff Moden function".
Jun
10
revised Getting a total value for items obtained in the current quarter
removed a tag from the title, added a relevant tag
Jun
9
suggested approved edit on Getting a total value for items obtained in the current quarter
Jun
9
revised Can't connect to an Active Node in an Active/Passive cluster
added relevant tags, removed a tag from the title, improved formatting
Jun
9
suggested approved edit on Can't connect to an Active Node in an Active/Passive cluster
Jun
5
answered Ensure order when select two rows using two identifiers on the same column
May
29
comment SELECT DISTINCT on multiple columns
Or maybe I misunderstood. When you said "faster" about the less verbose version of my suggestion, did you mean faster than mine or faster than the SELECT DISTINCT with unnest?
May
29
comment SELECT DISTINCT on multiple columns
Interesting. I thought a comma join would be equivalent to a CROSS JOIN in every respect, i.e. in terms of performance too. Is the difference specific to using LATERAL?
May
28
comment Parameter Sniffing Question
A long procedure as in having many queries or having one big query? Have you tried determining which part of the procedure is responsible for the delays?