sql

sql multiple insert on one table, while looping/iterating over another table?

Hi Guys, I have two table "TempStore" and "Store" with the same column called "Items". There is data in "TempStore" table which I need to move over to "Store" table which requires few modifications. I need to iterate over "TempStore" data (i.e. items) and insert into Store... More specifically: How can I iterate over TempStore (in sq...

Fetch database information on a new page without using new documents

I'm working on a page where I've listed some entries from a database. Although, because the width of the page is too small to fit more on it (I'm one of those people that wants it to look good on all resolutions), I'm basically only going to be able to fit one row of text on the main page. So, I've thought of one simple idea - which is ...

SQL Select Count(person_id) > 3 From...

Can someone convert this english to SQL I have tried several things but no luck. SELECT CASE WHEN COUNT(person_id) > 3 THEN person_id end FROM table I am trying to only get the person_id(s) that occur > 3 times in the table. ...

Writing a dreaded SQL search query (2nd phase)

I am working on a search query (with an asp.net 3.5 front end) which seems quite simple, but is quite complex. The complete query is: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[usp_Item_Search] @Item_Num varchar(30) = NULL ,@Search_Type int = NULL ,@Vendor_Num varchar(10) = NULL ,@Search_User_I...

SQL possibly not returning values for a query in visual basic

In my code I enter a string in a text box and have the query check the server for the entry. If it exists it returns the string and the date into two separate variables. The database only has TrackingNumber and Date. Below is the code. As of right now i get "Invalid attempt to read when no data is present." at the "If (sdr("TrackingNumbe...

Select from two tables to find vat rate based on effective date

Hi, I have this two tables: mysql> desc vat_rates; +-------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+-------+ | rate_id | varchar(5) | NO | PRI | NULL | | | name | varchar(255) | ...

Gridview invalid column name

I have a gridview0 in a multiview and when I click select on a row I have the GridView0_SelectedIndexChanged sub change to a different view in the multiview, which has a different gridview1 but the same datasource as gridview0. This is when it errors out and it displays the invalid column name error, with the column name being the datak...

Oracle SQL script giving errors!

I get this error when trying to run this Oracle SQL script. Any help please? Error messages ((29,21) expected token:; [ ) * + , - / = > DROP WHERE HAVING AND OR NOT ON JOIN FROM GROUP ((34,21) expected token:; [ ) * + , - / = > DROP WHERE HAVING AND OR NOT ON JOIN FROM GROUP ((39,21) expected token:; [ ) * + , - / = > DROP WHERE HAVI...

SQL Join Ignore multiple matches (fuzzy results ok)

I don't even know what the name of my problem is called, so I'm just gonna put some sample data. I don't mind fuzzy results on this (this is the best way I can think to express it. I don't mind if I overlook some data, this is for approximated evaluation, not for detailed accounting, if that makes sense). But I do need every record in TA...

SQL Script Help, combine two queries into one

I was wondering if these two queries could be combined into a single query? Query 1: to get the @guidID to be plugged into Query 2: DECLARE @guidID uniqueIdentifier SET @guidID = (SELECT guidID FROM dbo.table1 WHERE IntID = 1) Query 2: retrieves a combined table from a function and table1 SELECT o.guidID, IntID, Title, func.Nam...

asp.net membership - sql authentication

I want to know whats the "right" way to setup membership in a new website. When i have new project i can go to Website/ASP.NET Configuration. There i can setup Forms authentication and manage all users that will be using this page. I can make roles and rules on folders. All of this info are saved into table that will be saved locally in...

Is there somewhere I can submit SQL code and have the website display a graphic?

I'm trying to create a graphs of my database. Is there somewhere online that offers this service for free? I think it would be a great tool. :) EDIT: Turning this CREATE TABLE pertipoempleado ( id_tipoempleado INT primary key, descripcion VARCHAR2(200) ); CREATE TABLE perarea ( id_area INT primary key,...

How do you update a DateTime field in T-SQL?

The following query does not update the datetime field: update table SET EndDate = '2009-05-25' WHERE Id = 1 I also tried it with no dashes, but that does not work either. ...

SQL Insert in an AJAX form

In a database where there is a many to many relationship (say 3 tables like this for example) Book | Author | BookAuthor _____ | ______ | __________ BookId | AuthorId | BookId Title | Name | AuthorId ... | ... | I want a form to create a new book. In that form, the users would enter...

How to calulate a number in a table from a different field in the same table?

Say I have a basic table, products, with 3 fields, productname, cost, and costnotax. Is it possible to automatically fill in the costnotax field by subtracting a percentage from the cost field? ...

How to connect an existing SQL Server login to an existing SQL Server database user of same name

Is there a SQL Server command to connect a user of a single database to a login for the database server of the same name? here's the example: Database Server - Default Instance Database: TestDB Server Login - TestUser Existing user on TestDB - TestUser If I try to make the TestUser login a user of the TestDB database, the "User, grou...

Querying a database or a datatable for duplicate records in one column

On MS access, how to get the "ID" of the records having duplicate content on the "myData" column ? something like : ---------------------- ------------------------ ID | myData | | ID | myData | ---------------------- ------------------------ ...

Mysql Many to Many with Count and math

I have a many to many table setup in my mysql database. Teams can be in many games and each game has 2 teams. There is a table in between them called teams_games. What I am looking to do is create stats for each team. An ideal printout would be: team_id, team_name, wins, losses, draws, error My problem is linking the math of which tea...

A quick SQL query to generate example data

I need to populate a currently empty table with a hundred or so fake records to simulate logins over the past two years to test my code with. The login table schema looks like: CREATE TABLE `Logins` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `User_ID` int(11) NOT NULL, `Date_Login` datetime NOT NULL, `Location` enum('site','admin'...

Optimal query to fetch a cumulative sum in MySQL

What is 'correct' query to fetch a cumulative sum in MySQL? I've a table where I keep information about files, one column list contains the size of the files in bytes. (the actual files are kept on disk somewhere) I would like to get the cumulative file size like this: +------------+---------+--------+----------------+ | fileInfoId | ...