Reputation
2,589
Top tag
Next privilege 3,000 Rep.
Cast close & reopen votes
Badges
10 28
Newest
 Good Answer
Impact
~108k people reached

Jul
15
answered Replace Yes with 1 and No with 0
Jul
15
comment Replace Yes with 1 and No with 0
Then just don't return t1.'Domestic Violence'n as DomesticViolence. What is the problem?
Jul
15
comment Pass parameters to a procedure with SQLcmd
Your SQLCMD command line doesn't contain or reference any query to execute. It should have either a -q "your_query" / -Q "your_query or a -i "sql_file". What script specifically are you executing with SQLCMD?
Jul
15
comment SQL Server tool for merging rows
Trying to understand this requirement: I just want a tool that lets me write a query that will find potential candidates – I'm not sure what kind of output you would need from such a tool that would help you to write a query to merely find potential candidates. Wouldn't it make more sense if the tool actually gave you all the potential candidates? Or is the problem that the rules for detecting them are not fixed (and so you want to script the rules yourself)? Otherwise it might be possible to write a query that would give you the potential candidates without any tool.
Jul
14
comment SQL Server tool for merging rows
How do you know that the two rows in your example belong together? Maybe you meant for them to have the same ID?
Jul
14
answered SQL Server transactional replication issue with database
Jul
14
revised Get all data from two tables and group it into different category in mysql
redundant characters in the code
Jul
14
revised Update one column based on count of records of grouped value in another column
added relevant tags
Jul
13
comment Applying GROUP BY when using multiple CASE WHEN
Your second GROUP BY should work for the desired output you've shown. So it may be something else you are doing that is wrong. Can you update your question with the actual query (or queries) where you were using group by e_id, CASE WHEN w_id in ('1','2') THEN w_id ELSE 0 END?
Jul
13
comment How to break down RELATIONAL data into HIERARCHY data structure?
@WhiteCrow: I've updated my answer. Next time please don't change your question once you've accepted an answer. Usually a new requirement should be a new question, unless it's something that really makes sense only as part of the original post. As a matter of fact, it would have been fine as a new question in this case too, I think, but it's all right this time, cheers.
Jul
13
revised How to break down RELATIONAL data into HIERARCHY data structure?
expanded following the update of the question
Jul
10
comment SQLITE Foreign key has to be re-added?
I doubt your question is answerable without knowing the definitions of the tables and the foreign key.
Jul
10
revised How to break down RELATIONAL data into HIERARCHY data structure?
minor clarification
Jul
10
revised Optimize a SQL query
added a reference
Jul
10
comment No advantage of using Cross Apply or CTE over inline sub-query
In a more general case, your inline queries will give you only one result per row, while joining to a CTE (which doesn't have to be a CTE, it could be a normal subselect) or CROSS APPLYing a row set can give you access to more than one column.
Jul
10
revised How to break down RELATIONAL data into HIERARCHY data structure?
added 217 characters in body
Jul
10
answered How to break down RELATIONAL data into HIERARCHY data structure?
Jul
10
comment Why should a key be made explicit?
They are not needed for your database to work but they are needed for your data to "work" i.e. be consistent, because that is exactly how you are telling your database server to keep the information consistent.
Jul
9
comment how to set “result to text” with a tsql statement in sp?
This would be a rough equivalent of Results to File rather than Results to Text, though.
Jul
9
awarded  Custodian