sql

Why doesn't this index work (Mysql)

I have this table: CREATE TABLE `maindb`.`daily_info` ( `di_date` date NOT NULL, `di_sid` int(10) unsigned NOT NULL default '0', `di_type` int(10) unsigned NOT NULL default '0', `di_name` varchar(20) NOT NULL default '', `di_num` int(10) unsigned NOT NULL default '0', `di_abt` varchar(1) NOT NULL default 'a', PRIMARY KEY ...

Shared "SQL Server 2005 Server Project" in Visual Studio 2008 Database Edition GDR 2

Hi after toying around with SQL Server 2005 Database projects, I have been pointed to the Visual Studio 2008 Database Edition GDR 2 extension (by our Microsoft rep), which allows for the creation of "SQL Server 2005 Server Project" projects. As far as I understand it, this lets you create a project with all the shared objects (logins b...

Connection Reset by Peer Error

Hi, I am getting the following exception [Microsoft][SQLServer 2000 Driver for JDBC]Connection reset by peer: socket write error Its happening on the application server when the web app tries to access a database located on another machine over a network. Now I have read some posts on this, and found many different answers. One wa...

SQL Inline or Scalar Function?

Hi, So I need an SQL function that will concatenate a bunch of row values into one varchar. I have the functions written but right now I'm focused on what is the better choice for performance. The Scalar Function is CREATE FUNCTION fn_GetPatients_ByRecipient (@recipient int) RETURNS varchar(max) AS BEGIN DECLARE @patients varchar(m...

Escaping SelectParameters in ASP.NET

I have the following SQLDataSource: <asp:SqlDataSource ID="topicSource" runat="server" ConnectionString="<%$ ConnectionStrings" SelectCommandType="Text" SelectCommand="SELECT * FROM tbl_Topic WHERE TopicId = @TopicId"> <SelectParameters> <asp:QueryStringParameter Name="TopicId" QueryStringField="id" /> ...

fake columns with union and two inner joins?

i've got this query: SELECT * FROM ( (SELECT ACCOUNTS.INSTALLTIME, ACCOUNTS.HONAME, ACCOUNTS.ADDRESS, ACCOUNTS.CITY, ACCOUNTS.STATE, ACCOUNTS.ZIP, ACCOUNTS.JOBNUMBER, ACCOUNTS.INSTALLDATE, ACCOUNTS.RESULT, ACCOUNTS.NOTES, ACCOUNTS.SMNOTES, technicians.technumber, technicians.boardplacing FROM ACCOUNTS INNER JOIN technicians ON ACCOUNT...

Is it wrong to have DB Server installed in the CI Server

Wondering what are the views on this We have a CI server that runs some integration tests on the DB server, and well... it just seems wrong to install a database server on the CI server to accommodate that More info to answer comment: Why is it necessary to do this? This particular part of the tests checks for db schema generation an...

Excel VBA - connect to sql with a trusted connection (no uid/pwd)

Is there a way to have Excel connect to Sql Server using the current user's network windows authentication (trusted connection/integrated security)? I don't want to rely on a sql login or have a uid/password in my code. ...

The "abc" parameter is missing a value

I'm having problems with a SQL Reporting Services 2005 report prompting for a parameter value, which is set as a list of values from a query. When navigating to the report directly, or using a "jump to hyperlink" and specifying the reports url, it works fine. However when it's accessed via a link from another report using "jump to repo...

WQL does not support TOP - need workaround

WQL (basically SQL for WMI) does not support the TOP keyword the way Sql Server and many other RDBMSs do (though the actual keyword is different sometimes but the concept is implemented.) Is there a workaround to emulating a SELECT query to behave as though it had a TOP clause that limited the result set? Or is there some other WQL-sp...

How to match columns in MySQL.

Everyone knows the "=" sign. SELECT * FROM mytable WHERE column1 = column2; However, what if I have different contents in column1 and column2...but they are VERY similar? (maybe off by a space, or have a word that's different). Is it possible to: SELECT * FROM mytable WHERE ....column matches column2 with .4523423 "Score"... I bel...

Oracle 10g : Monthly stats with grouping by file size

I am on Oracle 10g. I have a table that contains all the files stored in the system during the past year. I want to make statistical monthly deposits, grouping them by file size. eg 0-1m 1m-10m 10m-100m 100m + So my results would look like : Month, 0-1m, 1m-10m, 10m-100m, 100mplus 2009-03, 999, 999, 999, 999 I want to use Oracle's ...

Oracle: How can I select records ONLY from yesterday?

I've spent hours searching the web for an answer to this question... Here's what I currently have: select * from order_header oh where tran_date = sysdate-1 Thanks in advance. ...

SQL how to make one query out of multiple ones

I have a table that holds monthly data of billing records. so say Customer 1234 was billed in Jan/Feb and Customer 2345 was billing Jan/Feb/Mar. How can I group these to show me a concurrent monthly billing cycle. But also need to have non-concurrent billed months, so Customer 3456 was billed Feb/Apl/Jun/Aug SELECT custName, month, bill...

Is it possible to restrict the results of an outer join?

I've got a scenario where I need to do a join across three tables. table #1 is a list of users table #2 contains users who have trait A table #3 contains users who have trait B If I want to find all the users who have trait A or trait B (in one simple sql) I think I'm stuck. If I do a regular join, the people who don't have trait A ...

MySQL foreach ?

I have two database tables, users and logs. I need SQL code to do something along the lines of foreach(id in users) insert into logs a record with user_id = id; endforeach; I could use php to implement the foreach but I figured there is probably a pure SQL way of doing this. I'm running a MySQL server if that helps. ...

Denormalizing for sanity or performance?

I've started a new project and they have a very normalized database. everything that can be a lookup is stored as the foreign key to the lookup table. this is normalized and fine, but I end up doing 5 table joins for the simplest queries. from va in VehicleActions join vat in VehicleActionTypes on va.VehicleActionTypeId equals...

database query, giving unexpected result

I'm trying to keep track my students, and those that have not yet booked a lesson with me (I'm a music teacher as well as a CS student) but my attempt is actually giving me all those that HAVE already booked lessons, what is my mistake? SELECT DISTINCT student.person_id FROM student, lesson WHERE lesson.student = student.person_id AND...

How Can I truncate Multiple Tables in MySql?

I need to clear all my inventory tables. I've tryed SELECT 'TRUNCATE TABLE ' + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE 'inventory%' but I get this error: Truncated incorrect DOUBLE value: 'TRUNCATE TABLE ' Error Code 1292 if this is the correct way, then what am I doing wrong? ...

Query mySql with LIKE %...% and not pull false records

I've searched all around for a solution to this problem, but I can't seem to find one. Basically, it's this: I have a database that contains two fields that collect multiple values. For instance, one is colors, where one row might be "red, blue, navyblue, lightblue, orange." The other field uses numbers, we'll call it colorID, where one ...