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

1d
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
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".
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?
May
26
comment Outer left join with WHERE loses row
Because 'some value' != NULL doesn't evaluate to True. It doesn't even evaluate to False, it evaluates to Unknown (but is treated the same way as False in this case).
May
26
comment How to monitor history of logins to database if login auditing is not enabled?
The OP doesn't seem to be interested in index usage per se. They want the history of logins and they've only mentioned sys.dm_db_index_operational_stats because someone suggested that DMV as a way to get the information they want.
May
26
comment MYSQL - number of rows returned equals number of connections?
Whether the connection is dropped immediately after the query or not might depend on the architecture of your application or on the settings/capabilities of the middle tier that your application uses to actually connect to/communicate with the database. If the database component uses a server-side cursor for the result set returned, the connection may stay live all the time until you've finished working with the application or explicitly specified to close the connection.
May
20
comment SQL Server - Best practices on debugging extremely complex stored procedures
100+ parameters, but surely not all of them are mandatory? Perhaps there are patterns of parameter combinations that the procedures are supposed to be called with? I would start with finding and refactoring those.
May
15
comment Deep cloning a hierarchical database structure
If you are using SQL Server 2008+, take a look at this Stack Overflow question. Its Linked section can give you examples of usage of the method.
May
14
comment SQL Server 2012: set a column to only use a single case?
Or have a computed column for it that shows the UPPER/LOWER version, and read that instead of the source column.