sql

Retrieve names by ratio of their occurance

Hello, I'm somewhat new to SQL queries, and I'm struggling with this particular problem. Let's say I have query that returns the following 3 records (kept to one column for simplicity): Tom Jack Tom And I want to have those results grouped by the name and also include the fraction (ratio) of the occurrence of that name out of the tot...

SQL Reporting 2008. Local vs. Server. (Telerik reporting? )

I am trying to understand when we should use one over the other. From my understanding the local mode means you just bind data to a ReportViewer server control and it renders it as a report. The server version seem to be the same except it also comes with a Report Manager site and using a SQL DB. I am thinking that using the server ...

query multiple tables and combine results into one return table for stored procedure?

I have several different tables, but they all have 2 columns that are the same name. I want to write a stored procedure that searches one column in all of the tables and returns the result. Ideas? I'm fairly nub when it comes to SQL. ...

How to get a changeset SQL query using DB Pro for .net and SQl Server when usinga Team build?

Hi all, I am working on Build Automation via Team Build (TFS 2008). We are using DB Pro with our Web project. I want to get the SQL script for database change-set ,(that has occurred till the nightly build), automatically using MSBuild Script . This script has to bundled in a zip file along with Web Application binaries and pages. Ho...

SQL Query for inserting multi column values in to single column

I have Table "MultiCol" as below Name LibraryID RegisterID EngineerID Rahul 1002 4521 4854 Ajay 5072 3151 4833 Vimal 4532 4531 4354 I want to insert the Rahul's all IDs in the "SingleCol" table(shown below) which is having only one Column named "IDS" So I want the Result as shown below Table "Single...

Indexes and multi column primary keys

Went searching and didn't find the answer to this specific noob question. My apologies if I missed it. In a MySQL database I have a table with the following primary key PRIMARY KEY id (invoice, item) In my application I will also frequently be selecting on "item" by itself and less frequently on only "invoice". I'm assuming I would ...

Access is re-writing - and breaking - my query!

I have a query in MS Access (2003) that makes use of a subquery. The subquery part looks like this: ...FROM (SELECT id, dt, details FROM all_recs WHERE def_cd="ABC-00123") AS q1,... And when I switch to Table View to verify the results, all is OK. Then, I wanted the result of this query to be printed on the page header for a report ...

When are database triggers bad?

Possible Duplicate: Are database triggers evil? There is lot of negative information on database triggers, just want to get the community's take on when is it good vs bad. ...

What is the best practise for relational database tables in mysql?

Hi, I know, there is a lot of info on mysql out there. But I was not really able to find an answer to this specific and actually simple question: Let's say I have two tables: USERS (with many fields, e.g. name, street, email, etc.) and GROUPS (also with many fields) The relation is (I guess?) 1:n, that is ONE user can be a member of...

Understanding CGI and SQL security from the ground up

This question is for learning purposes. Suppose I am writing a simple SQL admin console using CGI and Python. At http://something.com/admin, this admin console should allow me to modify a SQL database (i.e., create and modify tables, and create and modify records) using an ordinary form. In the least secure case, anybody can access htt...

Oracle custom sort

The query... select distinct name from myTable returns a bunch of values that start with the following character sequences... ADL* FG* FH* LAS* TWUP* Where '*' is the remainder of the string. I want to do an order by that sorts in the following manner... ADL* LAS* TWUP* FG* FH* But then I also want to sort within each name in...

mysql faster way of matching an inner string

I'm trying to match on band names in a DB by excluding 'The' So a search for 'The Beatles' or 'Beatles' would both succeed. This is too slow: select * from artists where artist_name LIKE '%beatles'; Better ways to do this? I'd like to avoid having an extra sorting/matching column with 'the' stripped out. Thanks! ...

If/Then in SQL Embedded in VBA

I've got a string like this in my Excel VBA: strSQL = "SELECT * FROM Total WHERE (SimulationID = (" & TextBox1.Text & ") And Test1 = (" & Example & "))" However, sometimes Test will be 'is null', which makes the query And Example = is NULL How can I change it to add an if/then statement or something to make it say And Example is ...

SQL Express vs SQL Plus

Hi, I'm wondering what the difference is if any between SQL Express and SQL Plus. I know SQL Plus is used with Oracle but not sure if SQL Plus is a modification of SQL Express or a totally different installation. Thanks ...

INSERT SELECT Statement and Rollback SQL

Im Working on a creation of a query who uses INSERT SELECT statement using MS SQL Server 2008: INSERT INTO TABLE1 (col1, col2) SELECT col1, col2 FROM TABLE2 Right now the excecution of this query is inside a transaction: Pseudocode: try { begin transaction; query; commit; } catch { rollback; } If TABLE2 h...

SQL query not taking values more than 2100

SELECT MachineID, MachineName, count(ID) as Total, sum(Size) as TotalSize FROM Files join Machines on Files.MachineID = Machines.MachineID Where Files.MachineID In(sql.Append(string.Format("@MachineId{0}", i)); group by Files.MachineID,MachineName now when the machinId count is less than 2100 the query is performed and if it m...

sql server: permissions on table

SQL Server 2008 : How do I find out what kind of roles have what kind of permissions on a given table. Thank you in advance. ...

What does ‘?’ stand for in SQL?

I have this SQL by a programmer: $sql = " INSERT INTO `{$database}`.`table` ( `my_id`, `xType`, `subType`, `recordID`, `textarea` ) VALUES ( {$my_id}, ?xType, ?subType, {$recordID}, ?areaText ) "; My question is why is he using ? before v...

SQL Server Data Import with a "lookup"-- Hopefully a Simple Question

I have two databases, on two separate SQL Servers (trying to consolidate both). This is my setup, and I'm trying to import from Server1:Orders table to Server2:Orders table. Server1 Database1 Orders(ID, CustomerName, DateOrdered) Server2 Database2 Customers(ID, Name) Orders(ID, CustomerID, DateOrdered) ...

WCF fault logging and SQL Exception 4060 error.

I have been attempting to compile/run a sample WCF application from Juval Lowy's website (author of Programming WCF Services & founder of IDesign) for several days. The example app utilizes Juval's ServiceModelEx library which logs faults/errors to a "WCFLogbook" SQL database. Unfortunately, when the sample app faults, I get the followin...