sql

Inserting one lakh rows at a time .. error identity column violation

I'm trying to insert row by row in a table about 100k records.. I get this error after some 140 or so.. Violation of PRIMARY KEY constraint 'PK_table1'. Cannot insert duplicate key in object 'table1'. The statement has been terminated. In this case the primary key is an IDENTITY column. I do not include that column in my IN...

How do I break down MySQL query results into categories, each with a specific number of rows?

Hello, Problem: I want to list n number of games from each genre (order not important) The following MySQL query resides inside a ColdFusion function. It is meant to list all games under a platform (for example, list all PS3 games; list all Xbox 360 games; etc...). The variable for PlatformID is passed through the URL. I have 9 genres,...

sql exception when transferring project from usb to c:\

I'm working on a C# windows program with Visual Studio 2008. Usually, I work from school, directly on my usb drive. But when I copy the folder on my hard drive at home, an sql exception is unhandled whenever I try to write to the database. it is unhandled at the conn.Open(); line. here's the exception unhandled Database 'L:\system\pr...

SQL Server - Multiple Select with Duplicate Names

I'm trying to grab some data from my SQL database as below; USE exampleDatabase SELECT TOP(1) [Name] FROM [Peeps] ORDER BY [Weight] DESC SELECT TOP(1) [Name] FROM [Peeps] ORDER BY [Age] DESC The problem is when I read the data I get an error 'Name'. Dim byWeight As String = sqlReader.GetValue(sqlReader.GetOrdinal("Name")) Dim byAge A...

How to quote values using group_concat

I need to use group_concat to build a list of comma separated values but I need the values to be quoted. How do I do this? This: 425,254,431,53,513,13,1,13 Should be converted to: '425','254','431','53','513','13','1','13' ...

Parse error in PHP login form

I'm trying to have a login form in php. But my current code doesnt work. Here is the form: <form name="form1" method="post" action="loginverify.php"> <td><font size="3">Username:</td> <td></td> <td><input type="text" name="uname" value="" maxlength="15"/><br/></td> <td><font size="3">Password:</td> <td></td> <td><input type="text" name...

db2 sql scripts and newlines

Just getting started with db2. Quick question about giving it SQL commands from a file. If I run: db2 -f mySQLcommands and all my commands are one line sql commands they execute with no problems. if I put newlines in the middle of my sql statements then db2 comes back with "expected such and such a character after" Here is an examp...

sql to select top 10 records

I have the following table (points): recno uid uname points ============================ 1 a abc 10 2 b bac 8 3 c cvb 12 4 d aty 13 5 f cyu 9 ------------------------- -------------------------- What I need is to show ...

Migrating shape sql to something equally powerful

Hi, we are currently investigating a migration of an application that doesn't meet company standards. The application is built using VB6 and Shape SQL/Access. The application has about 120 reports by storing Shape SQL strings in a database which the user can modify using a wizard. Shape sql is not allowed at this company. We have invest...

Database doubly connected relationship inserting problem

I have two tables Plants and Information. For every plant there are many information, but for each plant there is a single MainInformation. So there is a one-to-many relationship and a one-to-one relationship between the two. The Information table has a PlantID and the Plants table has a MainInformationID. I want both fields in both tabl...

How to design tables that map the same entity ?

Given the two following tables : Gallery id | title | desc Site id | title | desc | url I've a tags system which can apply to both Gallery and Site tables. I'm wondering if I should do : TagMap tagId | entityId | applyTo Where applyTo could be 'site' or 'gallery' or use separate table like the following : TagGalleryMap tagId | g...

How to combine two result sets from one table sorted independently using one SQL query?

This is a simplified task which I have to solve in real project. In this project data is stored in HSQLDB. Data is accessed using JDBC. I have one table: name | flag ----------- aa | 1 bb | 0 cc | 1 dd | 0 ee | 1 ff | 0 I need to compose query to get the following table: name | flag ----------- aa | 1 cc | 1 ee | 1...

In .NET, Does SQL have any part in game development? Is it used for anything?

I'm a self teaching beginner, and I know absolutely nothing about the technical specs of computers/programming in general. I am using a C# book to learn it, and I mainly just want to learn everything that relates to game development, if something has no part in game development/no use in it. I won't bother learning it for the time being....

How to resolve concurrent transaction issues in sales database

My application is storing some data in SQL Table called Transactions. Users are able to sell something from Client1 to Client2 and then Client2 has it. I am storing it in a table the following way: Client 1 | Buy | Something | Price | External | Client 1 | Sell | Something | Price2 | Client 2 | Client 2 | Buy | Something | Price2 | C...

Continuously checking database from a Windows service

I am making a Windows service which needs to continuously check for database entries that can be added at any time to tell it to execute some code. It is looking to see if it's status is set to pending, and it's execute time entry is > than the current time. Is the only way to do this to just run select statements over and over? It mi...

Short Sql insert Statement?

In MySql I could have a table with an auto increment column and insert that way: INSERT INTO tbl VALUES(null, "bla", "bla"); Is there any way to do this with Microsoft SQL Server Express? Instead of this: INSERT INTO tbl(`v1`, `v2`) VALUES ("bla", "bla"); Thanks ...

Conversion of IF SQL from MySQL to PostgreSQL

I'm converting a PHP script as DB has been switched from MySQL to PostgreSQL. I know PG doesn't have the IF function but does have the CASE function. What is the best way to convert this MySQL statement? SELECT albums.id, albums.albumname, sum(if(((albums.id=allalbums.albumid) and (allalbums.photoid=...

what is the best database design for this table when you have two types of records

i am tracking exercises. i have a workout table with id exercise_id (foreign key into exercise table) now, some exercises like weight training would have the fields: weight, reps (i just lifted 10 times @ 100 lbs.) and other exercises like running would have the fields: time, distance (i just ran 5 miles and it took 1 hours) should...

unable to make out use of BETWEEN in oracle

I am not able to make this out: Between eliminates use of >= and <= ...but when i tried this query: SELECT * FROM names WHERE name >= 'Ankit' AND name <= 'P' ...it gives output: name ------ Ankit Mac Bob When I tried: SELECT * FROM names WHERE name BETWEEN 'Ankit' AND 'P' ...it gives output: name ------ Ankit...

how do i start to use SSRS?

i have sql server 2008. i would like to learn the reporting services. where can i start? can you show me a tutorial that helps me make a simple report. ...