sql

Is there a web site where I can paste a SQL Insert statement and have it break it out by column?

I've been working on an application that has no discernable data access layer, so all the SQL statements are just built up as strings and executed. I'm constantly confronted by very long INSERT statements where I'm trying to figure out what value in the VALUES list matches up with what column in the column name list. I was about to cre...

SQL Server 2008 - Full Text Query

Hello, I have two tables in a SQL Server 2008 database in my company. The first table represents the products that my company sells. The second table contains the product manufacturer’s details. These tables are defined as follows: Product ------- ID Name ManufacturerID Description Manufacturer ------------ ID Name...

Starting to construct a data access layer. Things to consider?

Our organisation uses inline sql. We have been tasked with providing a suitable data access layer and are weighing up the pro's and cons of which way to go... Datasets ADO.net Linq Entity framework Subsonic Other? Some tutorials and articles I have been using for reference: http://www.asp.net/(S(pdfrohu0ajmwt445fanvj2r3))/learn/dat...

C# code for viewev tables

Can somebody write me a code, how to view data from tables in c# (using select statement)? I tried it myself and posted the code here, but i didn't get it right. Please help! ...

Tsql ordering data by specific string values

Hi every body I have an audit table that have data for insert, update and delete operations. I am writing a report that will display data in the order of Insert, Update and Delete. I don't think the order by clause will help. any help? ...

Unable create a table - ERROR 1064 (42000): You have an error in your SQL syntax

I'm trying to execute this simple command: create table foo (clo int primary key unsigned auto_increment); But I get this error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unsigned auto_increment)' at line 2 ...

Keeping the data in memory or sql database

I'm trying to learn SQL to store the data rather than reading the file and populating the whole data structure in memory. would it be like reading the data from disk instead of direct memory? ...

sybase 'drop procedure'. can I get it to take a parameter instead of a naked proc name?

Happy Monday o/ I'm looking to do the following within a stored proc select @parameter="fooproc" drop procedure @parameter instead of drop procedure fooproc But it's choking with a syntax error. Is there some way I can bend this to my will? I would've expected to be able to do this. I've tried a few permutations of type de...

Deleting certain rows based on the count of a column in the mysql database

Hi, I have a very large database with about 120 Million records in one table.I have clean up the data in this table first before I divide it into several tables(possibly normalizing it). The columns of this table is as follows: "id(Primary Key), userId, Url, Tag " . This is basically a subset of the dataset from delicious website. As I s...

SQL wont work? It doesn't come up with errors either

Hey there, I have php function which checks to see if variables are set and then adds them onto my sql query. However I am don't seem to be getting any results back!? $where_array = array(); if (array_key_exists("location", $_GET)) { $location = addslashes($_GET['location']); $where_array[] = "`mainID` = '".$location....

rails: include statement with two ON conditions

Hi, I have tree tables books bookmarks users where there is a n to m relation from books to users trough bookmarks. Im looking for a query, where I get all the books of a certain user including the bookmarks. If no bookmarks are there, there should be a null included... my sql statement looks like: SELECT * FROM `books` LEFT OU...

Using a set of numbers inside a database without creating a temporary table

I have a set of numbers and a table in a database with the id (primary key) and text (not null) columns. I would like to create a query that returns all the numbers in the set and the associated text from the table. Unfortunately not all numbers exist in the database's id column, so this won't work: select id, text from table where id i...

Oracle Query Optimization: Why is My Second Query Faster?

I was having some performance issues with an Oracle query, so I downloaded a trial of the Quest SQL Optimizer for Oracle, which made some changes that dramatically improved the query's performance. I'm not exactly sure why the recommended query had such an improvement; can anyone provide an explanation? Before: SELECT t1.version_id, ...

How to remove duplicate records in a table?

I've got a table in a testing DB that someone apparently got a little too trigger-happy on when running INSERT scripts to set it up. The schema looks like this: ID UNIQUEIDENTIFIER TYPE_INT SMALLINT SYSTEM_VALUE SMALLINT NAME VARCHAR MAPPED_VALUE VARCHAR It's supposed to have a few dozen rows. It has about 200,000, most of which are...

is it possible to select EXISTS directly as a bit?

I was wondering if it's possible to do something like this (which doesn't work): select cast( (exists(select * from theTable where theColumn like 'theValue%') as bit) Seems like it should be doable, but lots of things that should work in SQL don't ;) I've seen workarounds for this (SELECT 1 where... Exists...) but it seems like I shou...

SELECT subset from two tables and LEFT JOIN results

Hi all, I'm trying to write a bit of SQL for SQLITE that will take a subset from two tables (TableA and TableB) and then perform a LEFT JOIN. This is what I've tried, but this produces the wrong result: Select * from TableA Left Join TableB using(key) where TableA.key2 = "xxxx" AND TableB.key3 = "yyyy" This ignore cases where key2=...

SQL server 2008 trigger not working correct with multiple inserts

I've got the following trigger; CREATE TRIGGER trFLightAndDestination ON checkin_flight AFTER INSERT,UPDATE AS BEGIN IF NOT EXISTS ( SELECT 1 FROM Flight v INNER JOIN Inserted AS i ON i.flightnumber = v.flightnumber INNER JOIN checkin_destination AS ib ON ib.airport = v.ai...

c# - SQL - speed up code to DB

I have a page with 26 sections - one for each letter of the alphabet. I'm retrieving a list of manufacturers from the database, and for each one, creating a link - using a different field in the Database. So currently, I leave the connection open, then do a new SELECT by each letter, WHERE the Name LIKE that letter. It's very slow, thoug...

SQL finding overlapping of times pass midnight (across 2 days)

Hi everyone, I know there are lots of these types of questions, but i didn't see one that was similar enough to my criteria. So i'd like to ask for your help please. The fields i have are just start and end which are of time types. I cannot involve any specific dates in this. If the time ranges don't go pass midnight across day, i'd jus...

inserting a datatable to the database in c#

i have filled a datatable with rows. now i need to insert the rows of the datatable to a table in my database. how can i do this? et la 2ayre mahadan yridd!! ...