sql

how can I program in ASP.net using PHP like methods

I am a PHP programmer and I want to develop a website using visual web developer .net I knew that asp.net has many different approaches in dealing with database. However, I am familer with PHP way in programming for example: $query = "select * from table where user_id > 2" $result = mysql_query($query); while($row = mysql_fetch_array($...

if exists statement in sql to linq

What is the linq equivalent of the following statement ? IF NOT EXISTS(SELECT UserName FROM Users WHERE UserName='michael') BEGIN INSERT INTO Users (UserName) values ('michael'); END also can you suggest any sql-to-linq converters? I am currently using LINQPad which does a great job in terms of writing linq code where you can also see...

SQL Server to mySQL converter

Hai Techies, I have some stored procedure which was written in SQL server.Now i want to migrate this to mysql.Is there any freeware tools which can do this for me. ...

What are some good sql databases for home Vista computer?

I have been trying for a long time to get SQL Server Express on my computer to practice my C#/SQL with and I still haven't gotten it to work. Are there other programs I can use to setup an SQL database to practice with? If so, which are the best ones for Vista? EDIT: To be clear I am not new to SQL programming, I just haven't done a...

Linq to SQL Case WHEN in VB.NET?

How do I do a Case WHEN in Linq to SQL (vb.net please). In SQL it would be like this: SELECT CASE WHEN condition THEN trueresult [...n] [ELSE elseresult] END How would I do this in Linq to SQL? ...

Is SQL the assembly language of the modern world?

Duplicate of: Is SQL The Assembly Language for Databases? Please read and respond to that question Based on this post from los techies, I would like to ask if you consider this to be true. ...

[MYSQL & PHP] Searching two tables

I currently have following two tables: **files_list** -listid -name -synonym -description **files_tags** -tag_name -listid If someone uses the keyword "dragon ball", at the moment, I use following query to search my_list for possible matches: **SELECT * FROM `files_list` WHERE ( name LIKE '%dragon%' OR synonym LIKE '%dragon%' OR des...

Problems with big query and subquery

I thought that I'll be clever and use subquery to get my report in one go. But after running into problems and reading documentation I saw that my approach does not work in MySQL. My inner query returns ~100 records and outer query scans 20000 records. When I restricted outer query to 20 records then it run 20 sec - really slow. I wonde...

UserName or guid UserID?

When saving data in different sql tables, is it best to use the GUID userID or simply use the username? is there a performance difference when using guid? ...

SQL statement - "join" vs "group by and having"

This is a very basic query I can't figure out.... Let's say I have a two column table like this: userid - roleid 1 - 1 1 - 2 1 - 3 2 - 1 I want to get all distinct userids that have roleids 1, 2 AND 3. Using the above example, the only result I want returned is userid 1. How do I do this? ...

Is it possible to execute a stored procedure over a set without using a cursor?

I would like to execute a stored procedure over each row in a set without using a cursor with something like this: SELECT EXEC dbo.Sproc @Param1 = Table1.id FROM Table1 I am using T-SQL in SQL Server 2005. I think this might be possible using a function, but I'd like to use a stored procedure if possible (company standards) ...

Retrieve and print data from dynamic sql query with linq

I have some existing code that retrieves data from a database using ADO.NET that I want to convert to linq. What the code does is receives an SQL query via command line, executes it, returns the rows and their column names, then prints them to the screen. I would like to know how to write this code in linq. The ENTIRE sql query MUST...

What's the best way to select multiple M:N relationships in SQL?

I've embarked on a project which is encouraging me to expand my knowledge of SQL. I've already learned quite a bit, but I've gotten myself to a point where I can see a problem, but I don't know enough to properly research a solution. I've hit SO, Google, and the MySQL docs, but either I'm asking the wrong questions or I don't know how ...

How does normal SPs handle exception thrown by managed SPs

I read that SQL exceptions are treated as normal exceptions in managed SPs; I would like to know how is following scenario handled w.r.t to this. I have a normal t-SQL SP that calls a managed SP. managed SP throws exception due to some issue. How does normal T-SQL handle this. I have not tried this scenario yet as I do not have SQL s...

SQL Joins vs Single Table : Performance Difference?

I am trying to stick to the practice of keeping the database normalized, but that leads to the need to run multiple join queries. Is there a performance degradation if many queries use joins vs having a call to a single table that might contain redundant data? ...

Multi Rows Deletion from table in SQL Server

How I can Delete 1.5 Millions Rows From SQL Server 2000, And how much time it will take to complete this task. I dont want to delete all records from table.... I just want to delete all records which are fullfilling WHERE condition. EDITED from a comment to an answer below. "I fire the same query i.e. delete from table_name with Where...

Efficient join with a "correlated" subquery

Given three tables Dates(date aDate, doUse boolean), Days(rangeId int, day int, qty int) and Range(rangeId int, startDate date) in Oracle I want to join these so that Range is joined with Dates from aDate = startDate where doUse = 1 whith each day in Days. Given a single range it might be done something like this SELECT rangeId, aDate...

SQL full text search vs "LIKE"

Let's say I have a fairly simple app that lets users store information on DVDs they own (title, actors, year, description, etc.) and I want to allow users to search their collection by any of these fields (e.g. "Keanu Reeves" or "The Matrix" would be valid search queries). What's the advantage of going with SQL full text search vs simpl...

Linq to Sql: SubmitChanges() adds more objects to database then I've attached

I have the problem that when calling SubmitChanges() objects that have not been attached to a collection or added using InsertOnSubmit(), are still being inserted into the database. I read online that when assigning an object to a property that represents a foreign key, this object is automatically added to the collection of objects to ...

Can I order by multiple columns and somehow keep the ordering related between columns in MySQL?

I know the title doesn't explain my question very well (if someone can come up with a better title then please edit it). Here's what I want to do, say I have the following table: id | a | b | c ------------------ 1 | 3 | 3 | 3 2 | 20 | 40 | 30 3 | 40 | 30 | 10 4 | 30 | 10 | 15 5 | 10 | 15 | 6 6 | 15 | 6 | 20 This is slight...