sql

storing images in sql server

I am trying to put together db design for storing images. Many of you might have had experience designing db to store images and the challenges associated with it. The db might store hundreds of thousands of images eventually. I am planning to use SQL Server 2008 db and entity framework. Planning to use FILESTREAM datatype for storing ...

SQL Selecting column names as values

I have a table of data with column names: period, Truck, Car, Boat Where the Columns contain numeric values, and the period column is an identity column having 1 to 48, so there are 48 rows. I would like to massage this table into a format where I have a Name column and a value column as well as the period column eg. period, NameOfV...

SQL Server 2005 - Are there any major negative implications to returning multiple tables w/ stored procedures?

I've run across multiple situations in the last few months where legacy sql SP's are returning a single table made up mostly of redundant information. Example: Select CustomerID, CustomerEmail, CustomerAddress, InventoryLineItem, ShipQty from ... Returns: 55 [email protected] 723 StreetName InvLineItem#1 45 55 [email protected] 723 StreetName InvLineIt...

The different combinations of join are confusing, can someone boil it down a little?

Looking at JOIN's this weekend. I was reading up on Join and seeing a ton of combinations of JOIN, LEFT, RIGHT, OUTER, FULL, INNER. I checked the MSDN docs and it looks like the only allowed combinations are in the form: < join_type > ::= [ INNER | { { LEFT | RIGHT | FULL } [ OUTER] } ] [ < join_hint > ] JOIN so from tha...

Need help with my query

Hi. Sorry for the horrible title, not sure how to explain this. I have a query that looks like this: SELECT `name`, `latitude`, `longitude`, `indoor`, `address`, `phone`, `email`, `website`, `closed` FROM rocks INNER JOIN (SELECT DISTINCT id FROM rock_types WHERE type="DWS" or type="Top rope") AS types ON rocks.id=types.id ...

Optimizing SQL data reader

I am using SQl data reader to get value from SQL database. Language VB.NET After getting data into reader, i run a while loop While reader.Read If reader.HasRows() Then /* Proessing of data */ End If End While I observe that the while loop takes a lot of time to process as there are many rows. Is there any bett...

SQL to get messages only from people I follow.

Hi guys, I'm wondering how to create SQL query to get messages only from people I follow. I assume that create a SQL join query is the right way but I don't know how. Please could someone help me? I have these three tables now: CREATE TABLE `users` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `username` VARCHAR( 255 ) NOT NULL , `...

SQLite - ORDER BY RAND()

In MySQL I can use the RAND() function, is there any alternative in SQLite 3? ...

how to write this sql

I'm using mysql there are two tables vote app_id user_id 2 1 3 1 2 2 app id title content 1 xx xxxx 2 yy yyyy 3 zz zzzz I want to sort app table by the number of user's vote . in this example , the result should be id title content 2 yy yyyy 3 zz zzzz 1 xx xxxx any suggestion? ...

Counting consecutive duplicate records with SQL

I have a data-analysis question, that I could easily solve with some T-SQL or some scripting, but I was wondering if there was a clever SQL solution. The problem is that it messes a bit with SQL's row-independence assumption a bit. I have a table that consists of name-value pairs associated with a user and ordered by submission, for exa...

Storing an image in MySQL

How can I store and retrieve an image to a MySQL database using VB.NET 2005? ...

How to do an update based on a count - SQL (postgres)

I have a table, let's call it 'entries' that looks like this (simplified): id [pk] user_id [fk] created [date] processed [boolean, default false] and I want to create an UPDATE query which will set the processed flag to true on all entries except for the latest 3 for each user (latest in terms of the created column). So, for the follo...

SQL Server Update Trigger, Get Only modified fields

I am aware of COLUMNS_UPDATED, well I need some quick shortcut (if anyone has made, I am already making one, but if anyone can save my time, I will appriciate it) I need basicaly an XML of only updated column values, I need this for replication purpose. SELECT * FROM inserted gives me each column, but I need only updated ones. somethi...

Finding ID having all values (mySQL, SQL)

Think about a table like this ID Value 100 1 100 3 101 1 101 4 102 2 102 5 103 2 103 4 104 1 104 3 105 2 105 5 The problem is, if I give values 2 and 5 I should get 102 and 105 which both 102 and 105 are having values 2 and 5 at the same time or if...

Combining ASP.net SQL 2005 Change Scripts

I have created several SQL database change scripts, and placed them in a folder. Is there an easy way of combining a few of them into one file or executable so that it's easier for my partner to execute them on his database? Thanks for any help! ...

Post Build in SSIS Project

I am trying to have a PostBuildEvent in my SSIS project. This is my original .DTProj file from a test project with one test package. <?xml version="1.0" encoding="utf-8"?> <Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <ProductVersion>10.0.2531.0</ProductVersion> <Sche...

Oracle Query Help - Using TOAD

Hi all, I have used this type of functionality before but is MSSQL but can't get it to work for Oracle, any tips? DECLARE MY_TBL NUMBER := 1; BEGIN IF(MY_TBL > 0) THEN SELECT * FROM MY_TBL ORDER BY MY_TBL_ID DESC; END IF; END; What I would like to have is a flag variable set to zero or one, if one display the re...

SQL SERVER - INSERT INTO.. SELECT.. results in different no. of rows inserted than in SELECT.. itself

Hi everyone, I'm executing simple insert query like below: INSERT INTO tbl_destination ... SELECT ... FROM [SomeOtherLinkedServer].tbl_source It results in 3'000'000 rows inserted to the destination table although the SELECT returns the 9'000'000 rows. What can be the cause? I'm using SQL Servers 2005 Standard edition. The destination t...

SQL join related question

Hi guys, I am having trouble with a SQL join question. I have a table EMPLOYEE with EmpID, FirstName, LastName, Email, Phone I have another table OTHERNAME with 2 fields "Name" & "OtherName". This table contains lookup values such as "James", "Jim"; "Thomas", "Tom"; "Steven", "Steve". I want to write a query which will return rows E...

MySQL groupwise limit query

Say I've got a table: create table foo ( corp_id int not null, tdate date not null, sec_id int unsigned not null, amount int unsigned not null, primary key (corp_id, sec_id, tdate) ); The following query will return the sum of the amount column for all corp_id's and dates: select corp_id, tdate, sum(amount) from foo group b...