1,630 reputation
619
bio website
location Ukraine
age
visits member for 2 years, 6 months
seen 8 hours ago

Aug
12
comment scramble the value of one column and unscramble it?
On the other hand, why do you need to be able to restore original values?
Aug
12
suggested suggested edit on scramble the value of one column and unscramble it?
Aug
2
comment Select rows after a specific ID
@AdamHaines: In SQL Server 2012, it is possible to solve this without ROW_NUMBER. Please see my answer if you are interested.
Aug
2
revised Select rows after a specific ID
deleted 193 characters in body
Aug
2
answered Select rows after a specific ID
Aug
1
comment How to do aggregate functions in GROUP_CONCAT
Have you tried looking at the resulting query that you are executing eventually? I'm still not sure what the calculations must be but I suspect your last attempt is not bringing your the results you were hoping for. Just look at the query. It seems like you are trying to build a query without having a firm idea what it should look like. I suggest you first try writing a complete static query that does what you want. Basing off the static query, it will be easier for you to figure out how to construct it dynamically.
Aug
1
comment How to do aggregate functions in GROUP_CONCAT
You don't have (nor need) to put all the code into your question. Put only most relevant parts that need to be shown exactly and explain the rest in simple terms, leaving the Fiddles only as (helpful) illustration. Same for the sample data, which you don't need to present as DDL/DML in the question. Talking of the data, it would also be a good idea to simplify your problem in terms of tables and columns involved so that you could easily show in your question what you are trying to do and not fear that the length of your question might drive away potential answerers.
Aug
1
comment Distinct rows from a join
The result set of a SQL query is a table, a set of rows and columns. If some of the rows belong with one another based on certain criteria, some of the values must be repeated to indicate that. If you want to avoid the repetition in the output, then you are dealing with a presentation issue, which, accordingly, should be addressed at your presentation level (typically your application). If, however, you are positive that in this case you want the query to be your presentation level and return a result set already prepared for display, please tell/show us what the output should look like.
Aug
1
comment How to do aggregate functions in GROUP_CONCAT
You are trying to use a column list as the argument (list) of SUM() (twice), but SUM accepts only one argument (column or expression), not a list. Because of the incorrect use of SUM(), it is not entirely clear what you are trying to achieve. An example of the expected output (output resultset) might help. Also, please consider putting the relevant parts of your code and sample data into your question. I like SQL Fiddle very much but that doesn't prevent it from falling sometimes. Just imagine it stops working at this very minute, what then? Your question will stop making much sense.
Jul
31
comment SQL Server Management Studio 2012 - horrible blue background
@MartinSmith: Yes that one, and the overall theme is blueish as well: menus, panels, status bar etc. (I have no problem with it, just clarifying.)
Jul
31
comment SQL Server Management Studio 2012 - horrible blue background
@MartinSmith: They may be referring to the blue colour of SSMS 2012's empty workspace. @ paulH: Could you post a picture of what you are talking about, just to clear any doubts?
Jul
31
comment select query not displaying column names with records
Something to do with the settings of the tool you are using, perhaps? Is it only this SELECT that returns the result without the column name or do you observe the same behaviour with other SELECTs?
Jul
30
comment update statement with self join
Oh, how silly of me! You are right of course, using scalar subqueries doesn't make much sense here. Don't know how I was reading the question that I managed to miss that. This one might do better: UPDATE address SET col1 = a2.col1, col2 = a2.col2, ... FROM address a1, (SELECT * FROM address WHERE id = @from) a2 WHERE a1.id = @to;. Don't know if Sybase would allow a subquery in that context, though. And certainly the syntax is less elegant than yours, it's just that it might be less ambiguous to the peruser this way.
Jul
30
comment update statement with self join
As it's a single row & column to update and a single row & column to read from, I would try something like this, probably: UPDATE address SET col1 = (SELECT col1 FROM address WHERE id = @from) WHERE id = @to;. And sorry, I was incorrect: the subquery isn't a correlated one (it is not correlated with the main statement's row set, it is just a subquery returning one of the columns from one specific row).
Jul
30
comment update statement with self join
As an attempt at a guess (I'm not a Sybase expert), which may have been your guess as well, perhaps the first instance is being taken to be the target of the update. If you haven't found that out for sure in the meantime and you'd like to be certain your statement always updates the intended instance, you could use a correlated subquery instead of a join. Don't know whether the former would be less efficient than the latter in Sybase, though.
Jul
27
comment Figuring out database timezone
To the attention of @MattJohnson, as well as all the others, who may be considering a downvote on this, the issue has been raised here: meta.dba.stackexchange.com/questions/1007/possible-bug-in-data
Jul
24
revised sys.fn_varbintohexstr returns NULL if varbinary data is more then 2000 as datalength
fixed word order, added the footnote symbol near the product name referenced by the footnote
Jul
24
suggested suggested edit on sys.fn_varbintohexstr returns NULL if varbinary data is more then 2000 as datalength
Jul
24
comment LIKE uses index, CHARINDEX does not?
Do you happen to know if the PATINDEX() > 0 form uses the special statistics as well as the LIKE one?
Jul
23
comment Do database engines update when the updated value is the same?
@AdamB: It may still not be too late to do that.