sql

DataRelation from a single query

Hi, i have the following piece of VB.NET code: Dim conn As New MySql.Data.MySqlClient.MySqlConnection(ConnectionString) conn.Open() Dim sql = "SELECT * FROM users" Dim com = New MySql.Data.MySqlClient.MySqlCommand(sql, conn) Dim ds As New DataSet("dsUsers") Dim da As New MySql.Data.MySqlClient.MySqlDataAdapte...

How can I practice my SQL Server, Sybase, and Oracle skills on a linux box?

I have a linux box. When I had a Windows box, I was able to download the free non-commericial use MS SQL Server. How can I run free personal copies of SQL Server, Sybase, or Oracle on my linux box? I don't need to to have any permanent databases or any great amount of storage. I just want to (re-)familiarize myself with these differen...

How to apply <p></p> tags to a text field

Hi all, I've got a varchar() field in SQL Server that has some carriage return/linefeeds between paragraph marks. I'd like to turn it into properly formatted HTML. For instance: ---------- before ---------- The quick brown fox jumped over the lazy dog. Then he got bored and went to bed. After that, he played with his friends. ...

Parsing a variable within SQL result

I'm currently building an affiliate program (a bit like CJ) with Paypal checkout. When people sign up as an affiliate (=to sell their own products from their own website) they receive 2 php lines that they have to insert into their shop. In the header: <?php include 'http://www.mydomain.com/tracker/tracker.php?xyz='.$_GET[xyz]; ?> In...

Microsoft Jet wildcards: asterisk or percentage sign?

What is the proper multi-character wildcard in the LIKE operator in Microsoft Jet and what setting affects it (if any)? I am supporting an old ASP application which runs on Microsoft Jet (on an Access database) and it uses the % symbol in the LIKE operator, but I have a customer who apparently has problems in his environment because the ...

Sample database for exercise

I would like to play with a larger database to test my knowledge on SQL. Is there a huge .sql out there that I can use to play with SQL queries? ...

Storing folder hierarchy in relational database

I have objects representing folders and I'm wondering if they should be represented in the database. On the one hand it seems like the easiest way would be to not represent folder objects and just store a path value for objects contained in a folder. Problems I see with this is that you can't persist an folder whose descendants do not ...

Generating SQL Tables on the fly as new content is uploaded - A bad idea?

I have an interesting problem which I've been looking into and would appreciate some advice: I'm trying to create a tool which mimics the basic capabilities of a requirements management tool as part of a company project. The basic design is a Windows Explorer-like setting of folders and documents. Documents can be opened in a GUI, edit...

AFTER INSERT Trigger for SQL Server to create unique random 8 character code?

I started with some stored procedure code by Raymond Lewallen for a password generator. I would like to create a trigger that will create a unique 8 character ID each time a new row (a customer) is inserted. What I have so far: CREATE procedure dbo.AllAccessIDgenerator (
   @showID varchar(40) @accessID varchar(100) O...

SQL Transactions (b)locking Selects - is my understanding correct

We are using ADO.NET to connect to a SQL 2005 server, and doing a number of inserts/updates and selects in it. We changed one of the updates to be inside a transaction however it appears to (b)lock the entire table when we do it, regardless of the IsolationLevel we set on the transaction. The behavior that I seem to see is that: If yo...

SQL efficient nearest neighbour query

I'm having trouble coming up with an efficient SQL query to handle the following situation: Assume we have a table with two columns groupId : int value : float The table is huge (several million rows). There are a varying amount of "values" per "groupId" - say something between 100 and 50.000. All float values are greater or equal t...

Find what Foreign keys are in use

I have about 50 tables with created-by and changed-by referencing the user table. When I want to delete the user, I would like to create a list of what tables this user has data in, so one can go delete/edit everything belonging to said user. Is there any way of doing this in SQL? ...

Sub select issue

Hi, I'm trying to do a subselect in SQL on an AS400 and getting a "Data conversion or data mapping error" - I'm pretty sure its to do with the way SQL is handling dates in the subselect (specifically it's changing the format by adding commas into a decimal field and it's getting confused when it does the next select) - could someone conf...

Datawarehouse Question

I have a structure like this in a DB | RoleID | RoleTypeID | PersonID | OrganizationID | FromDate | ToDate | Each role is only valid for dates between FromDate and ToDate. Each person has a name, gender and birth date. I want to put this date into a data warehouse to use with SSAS. There I want to be able to build cubes with the nu...

Display a Photo Gallery using Asp.Net and SQL

I have recently added photos to my SQL database and have displayed them on an *.aspx page using Asp:Image. The ImageUrl for this control stored in a separate *.aspx page. It works great for profile pictures. I have a new issue at hand. I need each user to be able to have their own photo gallery page. I want the photos to be stored in th...

Field types available for use with "CREATE TABLE" in Microsoft Access

I have the displeasure of generating table creation scripts for Microsoft Access. I have not yet found any documentation describing what the syntax is for the various types. I have found the documentation for the Create Table statement in Access but there is little mention of the types that can be used. For example: CREATE TABLE Foo ...

Database-wide unique-yet-simple identifiers in SQL Server

First, I'm aware of this question, and the suggestion (using GUID) doesn't apply in my situation. I want simple UIDs so that my users can easily communicate this information over the phone : Hello, I've got a problem with order 1584 as opposed to hello, I've got a problem with order 4daz33-d4gerz384867-8234878-14 I want...

is it possible to delete from 2 or more sql tables using a sql datasource?

I am getting an FK error when i am deleteing a row from my datagrid because i cant see a way to delete from the oher table where the FK is then the main table? i am getting this error: The DELETE statement conflicted with the REFERENCE constraint "FK_Availability_Fixture". The conflict occurred in database "Rugby", table "dbo.Availabil...

SQL for counting events by date

I feel like I've seen this question asked before, but neither the SO search nor google is helping me... maybe I just don't know how to phrase the question. I need to count the number of events (in this case, logins) per day over a given time span so that I can make a graph of website usage. The query I have so far is this: select ...

concurrent queries in T-SQL

Hello All, I have a long stored procedure that does a lot of querying and generates a report. Since its a summary report, it calls a lot of other procs to get data. I am wondering if its possible to execute concurrent sql batches from with a proc in Sql server ... many thanks ...