I have a number of triggers which do various things, but at the top of all of those which have unique integer primary keys, I need them to auto increment. The code currently looks as follows: I thought it may be useful to make a small function for this, as I would if this were a conventional programming langu…
Tag: sql
Query Totaling Multiple columns and grouping by another
I am trying to get some totals of multiple records based on Location – but get totals for multiple columns to present back – basically there are various locations and each location has different species and totals at that location. Without doing something really ugly – I have no idea of the …
JPA with HIBERNATE insert very slow
I am trying to insert some data to SQL Server 2008 R2 by using JAP and HIBERNATE. Everything “works” except for that it’s very slow. To insert 20000 rows, it takes about 45 seconds, while a C# script takes about less than 1 second. Any veteran in this domain can offer some helps? I would app…
Storing a huge amount of points(x,y,z) in a relational database
I need to store a very simple data structure on disk – the Point. It’s fields are just: Moment – 64-bit integer, representing a time with high precision. EventType – 32-bit integer, reference to another object. Value – 64-bit floating point number. Requirements: The pair of (Mome…
Add/remove columns of a table – code maintenance / optimisation
What is the best way to maintain code of a big project? Let’s say you have 1000 stored procedures, and you have to add a new column to a table (or remove) There might be 1-2 or 30 stored procedures, that might be affected. Just a single “search” for the tablename might not be good enough, le…
SQL Insert Query Using C#
I’m having an issue at the moment which I am trying to fix. I just tried to access a database and insert some values with the help of C# The things I tried (worked) A new line was inserted and everything worked fine, now I tried to insert a row using variables: Didn’t work, no values were inserted…
Using HoldLock Incorrectly in SQL Server stored procedure
I believe I am using HOLDLOCK incorrectly. The reason I think this is because I have a table that acts like a queue. The queue receives its items from the SQL below and gets processed, one by one in a console application. I haven’t tested yet but I believe when this console application starts processing…
MySQL Query selection
I have a big database table called pricing. The fields are following: id code description rrp buy stock date distributor vendor version User select the vendor field only. version field can be vary …
SQL Find duplicate sets
given this Schema: table tblSET SetID int PK SetName nvarchar(100) Table tblSetItem SetID int PK ItemID int PK tblSetItem.SetID is a FK into the tblSet Table. Some data: …
Performing an UPDATE with Union in SQL
If I were to have these three tables (just an example in order to learn UNION, these are not real tables): Tables with their columns: And I wanted to update order_status in the Customer table when there is a order filled in either the Order_Web table or the Order table for that customer using Union: How can I…