sql

For Auditing Triggers or CDC

Hi All, I wanted to see if others are using SQL Server 2008 Change Data Capture and if so how do you like it? We currently use APEXSQL Audit Triggers for our auditing purposes which seems to work pretty well, but means we have to add triggers to all of our "audited" tables. Some of the articles I have read have pointed out things lik...

Capture USER_ID For Delete Operation

Hi All, We currently use Auditing triggers to track all of our DB changes. In order to capture the user_id for the person that submitted the delete we have to use an update and then have the trigger perform a delete so we can capture that USER_ID. Does anyone else use a different approach or have a better approach for this process? T...

Constructing sql in ruby on rails

The following SQL I am trying to run is returning sql_string of "SELECT id FROM people WHERE id IN ("16")": @ids = ["1", "6"] sql_string = <<-SQL SELECT id FROM people WHERE id IN ("#{@ids}") SQL Can someone please help modify the above query so it will create the sql_string of "SELECT id FROM people WHERE id IN (1, 6)" ...

SQL AdventureWorks count employees by gender by city

Hi, I want to count the cities by gender, like this; City GenderFCount GenderMCount Redmond 10 20 Here is my query gets city and gender in AdventureWorks database select Gender,City from HumanResources.Employee as t1 inner join HumanResources.EmployeeAddress as t2 on t1.EmployeeID = t2.EmployeeID inner ...

Learning resources for secure web development (SQL specifically)

I am a relatively experienced hobbyist web developer, but am concerned about my lack of knowledge covering potential security holes in web sites/services. I am looking for documentation covering best practices regarding security, especially when dealing with SQL databases. Attempts at searching are being thwarted by the fact that Google...

Storing multiple images in SQL Database

I'm trying to store three images from a form (PictureBox's) into a SQL Database (MSSQL2008) I'm new to programming and having a little difficulty simplifying my code. The below does what I want but is clearly inefficient. Any pointers on what to change to improve this? Private Sub SaveImages() Dim ConStr As String = "Data Sourc...

SqlDataAdapter can it be used to access oracle db?

SqlDataAdapter can it be used to access oracle db? yes it says sql, but can it be used for oracle ...

Need help with SQL ORDER BY

I have a table of contacts which has name and default_name columns among others. Contact name is name, unless name=NULL and then it is default_name (which cannot be NULL). I would like to order my selection by contact name. For example: contact_id name default_name ---------- ---- ------------ ...

SQL - Get answer from query as a single number

The following code returns a couple of numbers, identifying people who take part in more than three activities. SELECT pnr FROM Participates GROUP BY pnr HAVING count(activities)>3; I want the answer to be the number of people who participate in more than three activities though, i.e. "4", instead of four unique numbers. What to do? ...

Are Hierarchical Rowsets supported by JET and SQL Server?

The OLE DB documentation documents a hierarchial rowset feature, with SQL examples, but doesn't indicate what DB providers support it. Do JET and SQL Server support this feature? And do they use the same sort of syntax as in the documentation, or their own extended syntax? ...

Find last alphanumeric value in mysql

I have a field that contains usernames in a mysql db eg: johndoe2 johndoe10 johndoe3 If i order by that field DESC I get: johndoe3 johndoe2 johndoe10 I need to get: johndoe10 johndoe3 johndoe2 Any help appreciated ...

Unknown column 'xyz' in 'where clause'

i created a user defined sql query that doesn't work. users are supposed to be able to enter search strings in an input field, submit then see the results of their search but everytime i enter a search for something that i know is in the database i get the unknown column "x" in "where clause" error message. would you please help me fix...

What features should a new SQL-based Rapid Development tool have?

I am interested in developing a new SQL-based RDS which can generate prototype CRUD-oriented 4GL code which can then be easily customized. So I am looking for opinions, suggestions, etc. in what features should a new RDS have? I have looked at several products. FileMaker is more or less the type of product I'm looking for, but it's no...

Full Text Search - Select first lines

I have an application who saves some files in an sql database. I'm using Full text search for filtering on the documents, now i wonder if it's possible to select the first lines of a document? So i can make a sort of "google" page for my application ...

Getting only the default image for a property

I am trying to retrieve a list of properties and to do this I have to tie together 4 tables. The tables are: property, property_type, state, and photo. The problem is getting ONLY the default image for a property. The photo with the lowest rank number should be the default. So if there are 2 photos for property 10, than the one with t...

open source Java library of SQL utility functions?

I am looking for a SQL utility library that allows me to do things like escaping strings for prefix search using LIKE or programmatically writing the WHERE part of the query by adding terms (with placeholder support). ...

How to change characterset of an existing database for Interbase

We have a database and our client is written with Delphi 2007. The latest Interbase 2009 is used. The database is old, I believe it was created around 2002 and is now over 25 GB. Recently I discovered that in IBConsole upper('åäö') generate 'åäö'. It should be 'ÅÄÖ'. This is swedish characters that are missing in the English alphabet...

MSYSGIT BASH : Execute SQL against MS SQL Server

I'm running MSYSGIT on Windows and I want to be able to execute SQL statements against a SQL server directly from the bash console and bash scripts. Is this possible, and if so, how do I do it? Thanks! ...

Is it possible to perfom a fulltext search against a joined column?

Hello I' trying to select from joined column: SELECT A.idAd, A.ads_in_Cat, A.title, A.currency, A.price, A.in_dpt, A.description, D.*, S.* FROM ads A LEFT JOIN dept D ON D.id_dept = A.in_dpt LEFT JOIN sub_cat_ad AS ON S.id_sub_cat = A.ads_in_Cat WHERE MATCH(A.title, A.description) AGAINST(:searchTerm) ...

How to verify permissions on all SQL accounts along request sequence of ASPX page

I have a previously working ASPX website which also supports AJAX. However, we just upgraded our SQL Server from 2008 Evaluation to 2008 R2 version 10.50.16 and now this website is no longer working. I believe the problem is that now we need to again restore original SQL accounts and settings prior to this upgrade. This website also us...