I have a column with text/sentences that may include strings starting with ‘@’. I need to remove all strings starting with ‘@’ from the texts. For example: Is there any function that can do the trick? I have tried the following but this removes only the ‘@’ from the string:…
Tag: sql-server
Performance issue using IsNull function in the Select statement
I have a financial application. I have ViewHistoricInstrumentValue which has rows like this My views are complicated but the db itself is small (4000 transactions). ViewHistoricInstrumentValue was executed in less than 1 second before I added the next CTE to the view. After that it takes 26s. ActualEvaluation…
SSIS package works in debug mode, but hangs at step 2 when launched from the SQL Server job
Have a bit of a strange question here. We had a job in SQL Server that was being suspended on step 2 of an SSIS package. However whern I run the SSIS package in DEBUG mode it works fine. However if I launch the job from SQL Server it hangs at step 2. Step 2 basically returns about 2 million
Count amount of same value
I have a simple task which I to be honest have no idea how to accomplish. I have these values from SQL query: I would like to display a bit modified table like this: So, the idea is simple – I need to append a new column and set ‘Multiple’ and ‘Single’ value depending on if custo…
SQL query pivot, move values to top
I’ve created a PIVOT query and the results are fine, however. I would like to flatten the rows so to speak and move all values to the top of the list and NULLS to the bottom. http://sqlfiddle.com/#!18/7d17d/6 Instead of this: I would like to create something like this: Answer Change your ROW_NUMBER() to…
SQL Grand total without subtotals
I’m making a large SQL report in Orderwise, very roughly simplified as follows; I want a grand total at the bottom, without a bunch of subtotals dotted in throughout the report – therefore I don’t think I can use ROLLUP. The Subquery in there is of course a sub query and in the real thing th…
Need output by combining DATEDIFF(hh,StartTime,EndTime) + ‘Minutes’ in SQL Server
When running this query, I need output by combining I’m getting this error Conversion failed when converting the varchar value ‘Minutes’ to data type int I need to achieve the output like 15 Minutes. (15 represents the difference between StartTime and EndTime) Answer DATEDIFF function return…
Many conditions depends on IF clause within WHERE clause
How can I implement a WHERE clause that depends on one @value condition, like that pseudocode below: Answer As you’ve seen you can’t use an if like that, but you can create the desired behavior using the and and or logical operators:
Incorrect syntax near the keyword ‘INNER’ in sql update INNER JOIN
I tried to update some records by joining two tables. but It gives me some syntax errors. Please help me to fix this. Answer The correct syntax in SQL Server uses FROM: Note that I’ve also introduced table aliases so the query is easier to write and to read.
How to keep column name after sum aggregation in SQL query
I am querying SQL Server where I have multiple columns with sum aggregation. I’m wondering if there is a way to keep column name after doing sum over each of them. I want to avoid using aliases …