Hello,
I have a database on a SQL Server 2000 server. This database has a table called "Person" that has a field call "FullName" that is a VARCHAR(100).
I am trying to write a query that will allow me to get all records that have a name. Records that do not have a name have a FullName value of either null or an empty string. How do I g...
Hello
When using:
SELECT * FROM some_table WHERE id IN(4,2,1,3,5);
The resulting order is:
1,2,3,4,5
What can I do to return the results in the same order I queried them in?
thanks
...
Hello,
I have the following hsqldb table, in which I map UUIDs to auto incremented IDs:
SHORT_ID (BIG INT, PK, auto incremented) | UUID (VARCHAR, unique)
Create command:
CREATE TABLE mytable (SHORT_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, UUID VARCHAR(36) UNIQUE)
In order to add new pairs concurrently, I want to use t...
I'm having some trouble with a SQL Server 2005 database that seems like it's keeping a ghost constraint around. I've got a script that drops the constraint in question, does some work, and then re-adds the same constraint. Normally, it works fine. Now, however, it can't re-add the constraint because the database says that it already exis...
DoCmd.OpenForm "Database Search", acFormDS, , srcLastName & "AND " & srcFirstName
This is only a small sample of the where clause - there are many more terms.
First, there is a set of If, Then type tings up top that set the variable srcLastName and srcFirstName to some value. These are not the problem and work just fine.
The trouble i...
Okay I have two tables. They both have keys. I have another table that references both keys. How can I make a constraint when I add into that third if either of the keys don't exist in the first two tables it won't insert that tuple into the third table. I am inserting in phpMyAdmin. Thanks.
...
Currently we use separate a drop statements for each stored procedure in the script file:
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MySP]')
AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[MySP]
Is there a way to drop them all at once, or maybe in a loop?
...
I see various topics on this around stack overflow but none that fit the contect of MS-Access...
Given a starting date and an ending date, is there a way through SQL to return records for each given month within the time frame?
EG:
A record has a Start Date of #1/1/2010# and an End Date of #1/31/2010#
Running the query against that s...
I have a table that has a binary column that represents IP Address data. One of the queries perform a BETWEEN comparison on that binary column.
If I index that column, will performance improve for the BETWEEN comparison in the SQL Statement?
...
I have created a simple view consisting of 3 tables in SQL.
By right clicking and selecting Design, in the Object explorer table, i modified my custom view. I just added sortby asc in a field.
The problem is that the changes are not reflected in the outout of the View.
After saving the view, and selecting Open view the sort is not disp...
I have a SqlCommand object on my c# based asp.net page. The SQL and the passed parameters are working the majority of the time. I have one case that is not working, I get the following error:
String or binary data would be truncated. The statement has been terminated.
I understand the error and but all the columns in the database shoul...
I have followed scott's gu tutorial here
I uploaded the whole database to my site. Before doing what Scott's says I had one username stored in the membership. How can I create an additional user now that the table is in the web host? I can see that there's aspnet_Membership, aspnet_Applications, etc..etc
...
select SQL_CALC_FOUND_ROWS DISTINCT media.*, username
from album as album, album_permission as permission, user as user, media as media , word_tag as word_tag, tag as tag
where ((media.album_id = album.album_id and album.private = 'yes' and album.album_id = permission.album_id and (permission.email = '' or permission.user_id = '') ) o...
It seems to me that there are two scenarios in which to use JOINs:
When data would otherwise be duplicated
When data from one query would otherwise be used in another query
Are these scenarios right? Are there any other scenarios in which to use JOIN?
EDIT: I think I've miscommunicated. I understand how a JOIN works, what I'm not s...
I created some tables using MySQL Workbench, and then did forward ‘forward engineer’ to create scripts to create these tables. BUT, the scripts lead me to a number of problems. One of which involves the foreign keys. So I tried creating separate foreign key additions using alter table and I am still getting problems. The code is below (t...
AUTHOR table
Author_ID, PK
First_Name
Last_Name
TITLES table
TITLE_ID, PK
NAME
Author_ID, FK
DOMAIN table
DOMAIN_ID, PK
NAME
TITLE_ID, FK
READERS table
READER_ID, PK
First_Name
Last_Name
ADDRESS
CITY_ID, FK
PHONE
CITY table
CITY_ID, PK
NAME
BORROWING table
BORROWING_ID,pk
READER_ID, fk
TITLE_ID, fk
DATE
HISTORY ta...
Hi
I have three tables
Post
ID Name
1 'Something'
2 'Something else'
3 'One more'
Comment
ID PostId ProfileID Comment
1 1 1 'Hi my name is'
2 2 2 'I like cakes'
3 3 3 'I hate cakes'
Profile
ID Approved
1 1
2 0
3 1
I want to count...
I've spent a whole day on this already without figuring it out. I'm hoping somebody can help me translate the following MySQL query to work for SQL Server 2005:
SELECT MAX ( messages.date ) AS maxdate,
topics.id AS topicid, topics.*, users.*
FROM messages, topics, users WHERE messages.topic_id
= topics.id AND topics.user_id = user...
How to call stored procedure from another stored procedure and return the result as first one's column?
ALTER PROCEDURE [dbo].[GetItems]
AS
SET NOCOUNT ON
SELECT ID, AddedDate, Title,Description,
Result of Stored Procedure "CountAll" call with parameter ID as Total
FROM dbo.Table1
And also: how to be if CountAll stored proced...
I need to insert data into particular table through pl/sql stored procedure. My requirements are:
while inserting it should generate PRIMARY KEY values for a particular column;
it should return that PRIMARY KEY value to an output variable; and
for another column it should validate my string such that it should contain only characters, ...