Is it OK to swallow Duplicate key violation exceptions for INSERTS or should you check if the record exists? So let’s say that I have a table Photo with one field: PhotoName. I’m looking through a file directory to add items to Photo. In the process, it’s possible that when I find a photonam…
Tag: sql
Optimization of BigQuery aggregated data between two dates
I’m trying to compare the result of one query (example: number of rows), between the beginning of the current month and the current date, compared to what happened the previous month. Example: Today is 25/01, so I’d like to know the number of rows created between the 01/01 and 25/01, vs the previo…
Select info from a table referencing info from another table
I have a main product table with different products. Different products have different specs, so I’ve created separate specs tables for each product (there will be more than ten of them). What I want to do is to show individual product’s specs on a product_page.php whenever the product is clicked.…
SQL Server Reporting Studio report showing “ERROR#” or invalid data type error
I struggled with this issue for too long before finally tracking down how to avoid/fix it. It seems like something that should be on StackOverflow for the benefit of others. I had an SSRS report where the query worked fine and displayed the string results I expected. However, when I tried to add that field to…
SQL query by adding two columns in where clause?
I have a database table that contains two scores: scoreA scoreB I am trying to make a SQL query by adding these two values, such as However, it shows an error: Is there any way to work around for this? P.S. the reason I don’t add a new column for scoreC is because scoreA/scoreB are updated continuously …
Querying association table object directly
I have to query the relationships directly, since I have to display them seperatly. task_user = db.Table( ‘pimpy_task_user’, db.Column(‘task_id’, db.Integer, db.ForeignKey(‘pimpy_task.id’)), …
Why isn’t SQLAlchemy creating serial columns?
SQLAlchemy is generating, but not enabling, sequences for columns in postgresql. I suspect I may be doing something wrong in engine setup. Using an example from the SQLAlchemy tutorial (http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html): With this script, the following table is generated: However, a seq…
Calculate Count of true bits in binary type with t-sql
I need to find how many true bit exists in my binary value. example: Answer Result:
select NULL and false but not true in sql
i an new in vb.ner sql and what i am asking may be silly question. I have a table in sql server 2005 and a column name activated. this column contain NULL, true or false. I want to select only NULL …
Open and Close Cursors Inside or Outside a Transaction and How to Close a Cursor if a Transaction Fails
I am writing a stored procedure in SQL Server 2012 that uses a cursor for reading and a transaction inside a TRY CATCH block. Basically, my questions are as follows: Should I declare my cursor inside the TRY CATCH block? If yes, should I declare the cursor before or after the BEGIN TRANSACTION statement? Shou…