I am using SQL Server trying to replace each recurring “[BACKSPACE]” in a string and the character that came before the word [BACKSPACE] to mimic what a backspace would do. Here is my current string: “This is a string that I would like to d[BACKSPACE]correct and see if I could make it %[BACK…
Tag: sql-server
Getting the latest status of user before every calendar Date in SQL
I have 2 tables as below: Table 1: UserID DateEntered Status 1 29/03/2021 a 1 30/03/2021 b 1 31/03/2021 a 2 01/04/2021 a 3 02/04/2021 c 2 03/04/2021 c 3 04/04/2021 a 4 05/04/…
Counter Number of Times in State
I want to add a column which tells me the iteration count of how many times we’ve been in a state, ordered by date. We see we’re in state 1 for the first time, state 2 for the first time, then BACK to state 1 (iteration is now 2), the Iteration stays the same until we change state. I’d like
If I delete a record from a table it is deleted at many other places
I am working on a database built by the previous team. I have to delete certain records from a table (Example shown below). While doing this process, some records from the other tables with the same id is getting deleted. Could someone help how to overcome this problem? Answer In SQL Server, there is statemen…
Could a SELECT inside of a transaction lock the table?
I would like to know if it’s possible that a select is blocking a table if it’s inside a transaction. It’s something like this: It’s a dummy example, but if there’s a lot of records in that table, and an API is receiving a lot of requests and calling this stored procedure, could …
Tag a row based on aggregate value condition
Here is my dataset, where order is the fix sequence of each product. What I want is another column in here, lets say TagID. TagID is an int value that will based on the aggregate Count column, group it by product if it is greater or equal to 5. So the dataset would look like this: How can I accomplish
How to create a view using data from two tables
I have two tables ITEM id (int), model (varchar), weight (float), fk_type (int) TYPE id (int), name (varchar) And I want to create a view with TypeName (for every type name) –> varchar NumberOfItems (total number of ITEMS for TypeName) —> int NumberOfModels (total number of MODELS for TypeNa…
Get Current date, current month, current year depending on user selection – SQL stored procedure
I have a stored procedure that gives results depending on multiple values from the User(filtering), in my query I have 2 date columns date_start and date_end, I want to allow the user to return data depending on his selection from 2dropdownmenu one for start date and the other for end date as this: (this day …
Add multiplicity as rows
I use Sparx EA to build a relationship database (MS SQL Server). The tool has a function to create charts. I use the query: SELECT system.Name AS Series, systemElement.Name AS GroupName FROM t_object …
Scope_identity is giving null values? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question I have stored procedure in which I use scope_identity() Error I get: cannot insert null into i…