sql

Aqua Data Studio: Logs - who changes smth in db: data in table, or changed proc

How can I see logs, using Aqua Data Studio (I'm using MSSql db) - I need to see last change for a concrete table or procedure? And I can't add any security logic - only use default settings. I`m guessing there should be some global log, that is saving all changes, made to db. ...

SQL - fetch latest row with data in specific column or just latest row if no data in that column

I have a table that records a history of address updates, called transaction. The schema is something like row_id (int, PK), user_id (int), address1 (varchar), transdate (timestamp). I want to query the table and have a single row returned for a user showing what is the latest row (i.e. greatest timestamp), but if there is data in the ...

Finding value in a SQL table

Hi, I have a simple question here (I know it is so simple but I just got stuck...) I have a table tag_id, search_id 1,1 2,1 4,2 2,2 5,2 I would like to get the search_id by giving the tag_ids example: tag_id 1,2 would return search_id 1 tag_id 4,2,5 would return search_id 2 tag_id 2,6 would return no result. I should have pay more at...

MySQL: Unable to fulling forward engineering Sakila (sample) into server

After download the Sakila (sample), I have try to forward engineering this Schema into the server but only part of the table was engineered. Later synchronize also fall. Please take a look the report below and tell me is what wrong. I dont have programming background. If someone have successfully forward engineer Sakila fully, let me kn...

Using a variable in MySQL Select Statment in a Where Clause

I would like to know if it's possible to find a value in a select statement and use it in a where clause like: SELECT col1, MAX(col2) - COUNT(DISTINCT col3) as variable FROM table WHERE col1 > variable "table" is pretty big, and I want to narrow down the records the query has to look at as quickly as possible. I know this isn't bit ...

How to store sensitive information in SQL Server 2008?

I need to store some sensitive information in a table in SQL Server 2008. The data is a string and I do not want it to be in human readable format to anyone accessing the database. What I mean by sensitive information is, a database of dirty/foul words. I need to make sure that they are not floating around in tables and SQL files. At t...

asp.net mvc c# - problem with reading from sql server database

Hello all, I cant read any data from database, could you please look at my code and find a problem? cmd = new SqlCommand(); cmd.Connection = connection; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = @"SELECT ImageData, " + " ContentTy...

SQL Caching and Entity Framework

I have put together a small ASP.NET MVC 2 site that does some very extensive date mining/table-joins/etc. Using MVC, I have a controller that returns the data in many different forms (tables, images, etc). To save hitting the database frequently I have a dual cache mechanism: For identical parameters to the same action I use the O...

SQL Server/CF 3 - Merge Replication: Fails using Replication.SaveProperties when changing Subscription Info

I'm trying to use SQL Server/Compact Framework 3 Merge Replication functionality and am running into a problem when calling Replication.SaveProperties (using c#). I was hoping to get some clarification on whether its my interpretation on how things should work vs a coding problem. Basically, the Merge Replication seems to work as I can ...

SQL Set variable with single column in select field

I have a column along with many others that returns a int value. It is the same int value for every record in this column. If this value is 1 I need to set a variable = 1 if it is 0 i want the variable to be 0. How do I go about doing this? There can only be a 0 or 1 in that column. And again it is the same throughout the entire column...

Crystal Reports PostgreSQL inet query

I'm trying to create a report that allows a user to select a branch that they want to view traffic for in Crystal Reports 11. The data type in question is of the inet data type in PostgreSQL, I cannot change it. Because of this, it appears as though the "Like" operator will not work correctly. About the Inet Data Type: http://www.post...

Selecting Sets of Contiguous Events in SQL

Okay so right now I'm working on a program that has a whole bunch of event objects. Each event object has a start time and end time (both full timestamps). A lot of the events are contiguous (one event's endTime is the same as the next event's startTime) showing that the two events happened in succession. If I were to store all my events...

SQL get number of entries satisfying different conditions

Hi, the goal is to retrieve the number of users in one table which have: field EXPIREDATE > CURRENT_TIMESTAMP as nUsersActive field EXPIREDATE < CURRENT_TIMESTAMP as nUsersExpired field EXPIREDATE IS NULL as nUsersPreregistered all with one query, and the result should for example be nUsersActive nUsersExpired nUsersPreregis...

Get a complete list of unique values from multiple columns in multiple tables

Back story if you want it: I have an odd situation. An organization affiliated with my own provides us with a database that we use heavily; a few other organizations also use it, but our records are easily more than 90% of the total. We have a web frontend for data entry that is connected to the live database, but we only get the backe...

Conditional JOIN

I'm wondering if it's possible to accomplish this in MS Access 2007: A client gave me several tables, and they asked me for some queries. One of them has to get a field value from a table, depending on the value of a field of each record. This means, depending on the region, it has to look at one table, a second, or a third one. So, I ...

String concatenation does not work in SQLite

I am trying to execute a SQlite replace function, but use another field in the function. select locationname + '<p>' from location; In this snip, the result is a list of 0s. I would have expected a string with the text from locationname and the '<p>' literals. ...

How to optimize this low-performance MySQL query?

Hi there, I’m currently using the following query for jsPerf. In the likely case you don’t know jsPerf — there are two tables: pages containing the test cases / revisions, and tests containing the code snippets for the tests inside the test cases. There are currently 937 records in pages and 3817 records in tests. As you can see, it t...

SET OPERATIONS IN ORACLE 9i

Is it possible to do SET OPERATIONS using more than one column in the SELECT clause? For example: SELECT NAME, AGE FROM tableA MINUS SELECT NAME, AGE from tableB ...

Most efficient way of getting the next unused id

(related to http://stackoverflow.com/questions/3439571/finding-the-lowest-unused-unique-id-in-a-list and http://stackoverflow.com/questions/2116056/getting-unused-unique-values-on-a-sql-table) Suppose I have a table containing on id column and some others (they don't make any difference here): +-----+-----+ | id |other| +-----+-----+ ...

translate from SQL Server to Oracle

I was hoping one of you Oracle experts would be able to give me a hand with this. I have the following SQL Server script, but I need to rewrite it for Oracle: USE mydb GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE trigger mydb . [CONNECTERTRIGGER] on mydb . [DtreeNotify] FOR INSERT AS BEGIN IF @@ROWCOUNT=0 RETURN SET I...