Shortly, I am wondering which of the following is the better practice: to encapsulate my code in TRY/CATCH block and display the error message to write own checks and display custom error messages As I have read the TRY/CATCH block is not handling all types of errors. In my situation this is not an issue. I a…
Tag: sql-server
Insert Data Into Temp Table with Query
I have an existing query that outputs current data, and I would like to insert it into a Temp table, but am having some issues doing so. Would anybody have some insight on how to do this? Here is an example This seems to output my data currently the way that i need it to, but I would like to
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…
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…
php/mysql: get data from one table, convert and insert in another table
Ok I will try to explain, (I am Portuguese lol). I have a Database where I have the fallowing MySQL: Database: ad Table: notebooks Fields: ID, tag, so, lastlogon, lastlogh My ldap query gets data from ldap server (active directory) and stores it in my MySQL database (ad/notebooks). I get tag which is tag numb…
Backup a single table with its data from a database in sql server 2008
I want to get a backup of a single table with its data from a database in SQL Server using a script. How can I do that? Answer There are many ways you can take back of table. BCP (BULK COPY PROGRAM) Generate Table Script with data Make a copy of table using SELECT INTO, example here SAVE Table Data
Duplicate check using SELECT or rely on unique index?
Using SQL Server 2012. I want to insert unique strings into a table. I always want to return the row ID of the unique string. Now, this can be accomplished in two ways. Which solution is the best? This is the table in question: Solution 1: SELECT first to check if the string exists. If it does, return its ID.
Get number of employees who worked in more than one department with SQL query
I’m trying to figure out a query which show the number (amount) of employees who worked in more than 1 departments. Here the table name and fields: Employee(id_employee, employee_name, salary) Department(id_dept, dept_name, budget) Department_Employee(id_employee, id_dept, workhours_percentage) Suppose …
Return All Months & Years Between Date Range – SQL
I’m a bit stumped how I might go about this. I have a very basic query, that currently returns sales for each product, by year and month. It is grouping by year/month, and summing up the quantity. This returns one row for each product/year/month combo where there was a sale. If there was no sale for a m…
sql-ex exercise 39 failed on second server error?
Exercise 39: Define the ships that “survived for future battles”; being damaged in one battle, they took part in another. Database Schema: http://www.sql-ex.ru/help/select13.php#db_3 My approach: sql-ex says Your query produced correct result set on main database, but it failed test on second, che…