sql

Recursive t-sql query

Hi I have a table as shown below. ID ParentID Node Name Node Type ------------------------------------------------------------------ 525 524 Root Area Level 1 526 525 C Area Level 2 527 525 A Area Level 2 528 525 D Area Level 2 671 525 E Area Level 2 660 527 B Area Level 3 672 671 F Area Level 3 How can i write ...

Modeling Existential Facts in a Relational Database

I need a way to represent existential relations in a database. For instance I have a bio-historical table (i.e. a family tree) that stores a parent id and a child id which are foreign keys to a people table. This table is used to describe arbitrary family relationships. Thus I’d like to be able to say that X and Y are siblings without ha...

query the highest latest userid

I have a table with the following. The names are not unique. userid, name 1, dave 2, john 3, mike 4, mike 5, dave I want to return the unique name with the highest userid. ie. 2, john 4, mike 5, dave What is the query to do so? ...

SQL error 26=-error locatig server. ASP.NET

Hi All, I am trying to deploy my .NET webservice on to provider (somee.com). I published the webservice and copied the folder over to the hosting site. I have my App_data folder copied too. I can access the service webpage. But when trying to access the website I received the following error. I have sqlserver express on my local machine...

Find deleted records from a type-2 table, efficiently

I've got a database table of type-2 data, and I want to find records that were deleted since I last synced with it. It's got date_from and date_to columns, and the raw data has an ID column object_id. date_to<>null means it doesn't exist now, so if there's no other record with the same object_id and date_to=null, then it's been deleted...

Maintaining stored procedures in source control

How do you guys maintain your stored procedures? I'd like to keep versions of them for a few different reasons. I also will be setting up cruisecontrol.net and nant this weekend to automate builds. I was thinking about coding something that would generate the create scripts for all tables/sprocs/udf/xml schemas in my development dat...

change "many-to-many" to "one-to-many"

I have following table and data: create table Foo ( id int not null, hid int not null, value int not null ) insert into Foo(id, hid, value) values(1,1,1) -- use this as 1 < 3 insert into Foo(id, hid, value) values(1,2,3) insert into Foo(id, hid, value) values(2,3,3) -- use this as 3 < 5 insert into Foo(id, hid, value) valu...

design for 'simple' inventory system

Hello! I want to make a relational database system for a local computer hardware non-profit. There are two inter-related features that I want to figure out how to implement. First, we need to manage our inventory of parts, and second, we need to track donations of computer systems as they come into us, and also as we grant them out. Fir...

VB or C# for SQL Server - Just learning SQL Server (going from Access)

I am just getting into SQL Server, and I have some experience with MS Access an Visual Basic (well VB within Access anyway). So I am trying to acquire materials (books, etc) to learn how to program sql server, and I am wondering if I should go the C# route instead of visual basic for sql server?? not super familiar with c# (though i am ...

Creating DB using ORM

Is there any C# .NET ORM that can create databases ? It should be capable of creating MS + MySQL + PostGre + Oracle databases at least. And I don't mean tables or schemas, I mean the database only. I use nHibernate, but it can only create tables and schemas, and query/insert but not creating the database itself. ...

Having problems with sql triggers

Hi there, At the moment I am learning sql and begin to encounter problems with certain triggers. This is very basic but I do not know how to solve it. The problem is this: I have two tables Person and BankAccountInfo. The table Personincludes personal information. as identification number, name, birth date, etc. . TheBankAccountInfo` ...

SQL Server RowVersion

Hey guys, Quick question Re: Implementation of RowVersion. I am looking to include it in my next database (Designing it now) and I am pondering 2 different ways: RowVersion row in all tables A separate RowVersion table which has the ID of the table as a foreign key and linked to it. Anyone tried this? If so what pitfalls or pro's d...

Confused by: "when we design and optimize the stored procedures, we have to take into account that fact that they will be running on large database servers"

At work someone said "when we design and optimize the stored procedures, we have to take into account that fact that they will be running on large database servers". I'm confused by that statement in a number of respects: Does "large database server" imply a large volume of data and, if so, how does that impact the design of the store...

Speeding Up Update SQL Query

I am using following SQL over a SQL 2000 table, which contain around 100,000 records. It is very slow. How can I speed this up ? UPDATE [MASTER] SET [STATUS] = 1 WHERE [CODE] IN (" + *customerCodes* + ")"; customerCodes is passed from a UI where user can check customers from a grid. ...

SQL recursive query

Possible Duplicate: Recursive function in sql server 2005? How do you perform an iterative query on a table? I have a simple table which consists of a: KeyField, childID, parentID Starting with a childID, I want to pull the parentID and then query again to see if that parent (which is now the child) has its own parent, worki...

SQL delete orphan

Assuming that all foreign keys have the appropriate constraint, is there a simple SQL statement to delete rows not referenced anywhere in the DB? Something as simple as delete from the_table that simply skip any rows with child record? I'm trying to avoid manually looping through the table or adding something like where the_SK not in (...

SQL table - semi-unique row?

Hi I have an SQL table with basically the following structure: PK (int, primary key), userID (int), data (varchar 64) Basically, any user as defined by userID is allowed to store any number of short strings. However, no user is allowed to store two identical strings (although user 1 and user 2 can both store the same string separatel...

Embedded SQL in OO languages like Java

One of the things that annoys me working with SQL in OO languages is having to define SQL statements in strings. When I used to work on IBM mainframes, the languages used an SQL preprocessor to parse SQL statements out of the native code, so the statements could be written in cleartext SQL without the obfuscation of strings, for instanc...

Question about oracle xe search query

Hello all, this is my second time using ORACLE xe and Apex. Here is what I'm trying to do .. I'm trying to execute the following query SELECT * FROM EMPLOYEES WHERE JOB_TITLE = 'CLERK' but not from sql command prompt but from gui/apex and here is how- I have created page one with one textfield and one submit button. Now of course I'd...

please tell me what is error in this update query

UPDATE HotelSourceMap SET hsm.hotelid = co.hotelid FROM HotelSourceMap AS hsm JOIN hotels AS co ON (hsm.hotelname= co.[name] AND hsm.cityid = co.cityid) its giving me error: The multi-part identifier "hsm.hotelid" could not be bound. ...