sql

Problem with SQL query

Hello. Sorry, I couldn't provide a better title for my problem as I am quite new to SQL. I am looking for a SQL query string that solves the below problem. Let's assume the following table: DOCUMENT_ID | TAG ---------------------------- 1 | tag1 1 | tag2 1 | tag3 2 | tag2 3 ...

how to query a folder structure (files, directories)

I need to query folder structure. In other words I need to be able to access directory structure by SQL. I'm thinking of that there should be some OLE DB provider or some ODBC driver for that purpose. My friend said to google "folder monitoring" but I can't find anything Now I'm doing in command prompt dir>somefile and importing resulte...

custom sorting or ordering a table without resorting the whole shebang

for ten years we've been using the same custom sorting on our tables, i'm wondering if there is another solution which involves fewer updates, especially since today we'd like to have a replication/publication date and would'nt like to have our replication replicate unnecessary entries. i had a look into nested sets, but it does'nt seem ...

SQL Select Best practice

The following works, I'm just wondering if this is the correct approach to finding the latest value for each audit field. USE tempdb CREATE Table Tbl( TblID Int, AuditFieldID Int, AuditValue Int, AuditDate Date ) GO INSERT INTO Tbl(TblID,AuditFieldID,AuditValue,AuditDate) VALUES(1,10,101,'1/1/2001') INSERT INTO Tbl(TblID,AuditFieldID,Au...

Installing SQL Server Express 2005 - but it already exists on the machine

I built an application for a client that requires SQL Server 2005 Express. Everything worked fine on all the machines except for one. On this one they already had an application that uses SQL Server Express, so it was already installed on the machine, but nobody knows which application uses it or any usernames/passwords. Can I simply ...

Importing csv file to datatable returns no results

This method does not throw an exception, neither does it return the rows from the csv file it reads into the DataTable. I am at a loss for what I am doing incorrectly. Any help is much appreciated. public string ImportCsvFile(string filePath) { FileInfo file = new FileInfo(filePath); //string connString = "Provider...

SQL statement help -- Select customers who ordered today

Say I have a table which stores customers order IDs. Such as | Customer ID | Order ID | Order Date How can I get all customers who have ordered today? Also OrderDate would be a DateTime. Something like SELECT DISTINCT CustomerID FROM TableName Where OrderDate > Today But the last part is what I can't figure out. ...

how to create IDbDataParameter with null-able value?

I have add a null value to parameter list for inserting values to a table, which accepts some null values. Here is my example codes: bool sql = true; // .... List<IDbDataParameter> parameters = new List<IDbDataParmeter>(); // adding values... object objVal = 1; parameters.Add( sql ? new SqlParameter("@colIntA", objVal) : ...

How can I use the 'NVL' function on a result table?

select (t1.a + t2.b) sum from (select (aa + bb) a from table_x where cc = 'on') t1, table_y t2 where t1.id = t2.id The problem is that when t1 is not found, the final result will be null; How can I make the default value of t2.b to 0, when t1 is not found? Thx in advance. ...

a good tutorial for making a vb.net app to read / write SQL db

can someone please recommend some tutorials that show very simple examples on how one can read / rwite to an SQL db? ...

Why is there no equivalent for hierarchyid SQL data type?

I understand it that we have to map this type as binary to get to it in the application code. But why isn't there an exact equivalent with all those type methods? How are we supposed to work with in the code? Or we aren't supposed to work with it outside SQL environment at all? EDIT: The question extends to the geography and geometry t...

Updating Row with Subquery Returning Multiple Rows

I'm getting an error while updating the table with a subquery which should not have more than one value, but does. The query: UPDATE @Table1 SET D = t2.D + t3.D FROM @Table1 t1 INNER JOIN @Table2 t2 ON t1.P = t2.P INNER JOIN @Table3 t3 ON t1.A = t3.A ...

Update table with a subquery which is returning more than one row

SELECT (b.descr || ' - ' || c.descr) description FROM table1 a INNER JOIN table2 b ON a.account = b.account INNER JOIN table3 c ON a.product = c.product WHERE a.descr = ' ' ; How to update a table using the above subquery? its returning more than one row nearly 8000 rows? If you have any solutions for this please share with me?...

How do I search for a two character word using a MySQL query?

I'm using MySQL FULLTEXT search (in Natural Language mode). Example: SELECT Mem_id FROM Members WHERE MATCH (job_title) AGAINST ('".mysql_real_escape_string($keywordsWanted)."') I noticed that searching for "web developer" or "PHP coder" didn't work too well and so I added ft_min_word_len=3 to the MySQL config file (/etc/mysql/my.cnf)...

Flex and ASP.Net-Membership via WebORB

Have anyone done this? I'm putting the membershiplogic in a C# .dll, and the connection info in an app.config. When I try to use the C# .dll with another Windows C# console debug project I put the App.config in the consoles application directory, and calling the C# .dll-methods and it suceeds, I get a connection and it validates my user...

oracle -left outer join ANSI query

Hi All, I am executing the below query with Oracle ANSI left outer join syntax,It's returning 107 records: SELECT bs_accts.acct_num, bs_accts.acct_name, br_data.record_id , as_users.username, br_fx.fx_rate , FROM bs_accts CROSS JOIN as_users CROSS JOIN br_fx left outer join br_data ON ...

Bitwise operators in Postgres

I have a problem with using Bitwise operators in Postgres I get the following error message ERROR: argument of WHERE must be type boolean, not type integer My query looks as below SELECT DISTINCT number,name,contact,special FROM clients WHERE special & 2048; Any help will be appreciated ...

How can I optimise this MySQL query?

I am using the following MySQL query in a PHP script on a database that contains over 370,000,000 (yes, three hundred and seventy million) rows. I know that it is extremely resource intensive and it takes ages to run this one query. Does anyone know how I can either optimise the query or get the information in another way that's quicker?...

How to change the "Required" property of a column in Access?

In an access table I have a column which has the "Required" property set to "True". I need a query which would change it to "False". I tried the following without success: ALTER TABLE [MyTbl] ALTER COLUMN [MyCol] VARCHAR(30) NULL; ...

Slow SQL Updates within a Cursor

I've added a new column, packageNo, to my table: create table Packages( id varchar(20) primary key, -- ok, I know :) orderNo uniqueIdentifier not null, orderlineNo int not null, packageNo int not null default(0) ) Now I want to generate the packageNo with the following rules: reset it for each order ascendantfor order, or...