I'm having a problem that I can't figure out while converting a table field in an Oracle database to a CSV file. I have a column of varchar2(4000) where users enter their comments. Sometimes the users copy and paste text from other programs such as MS Word therefore, a lot of extra information is pasted into the field such as carriage ...
Hello -
I have this problem where I need to set "optional" parameters for my stored procedure to work fine.
For example, I have this:
CREATE PROCEDURE [dbo].[Search]
(
@StartTime datetime = NULL,
@EndTime datetime = NULL,
@CustomerEmail nvarchar(255) = NULL,
@OrderStatusID int
)
Now, in my .net website I have this like an exampl...
Is there any way to select a record and update it in a single query? I tried this:
UPDATE arrc_Voucher
SET ActivatedDT = now()
WHERE (SELECT VoucherNbr, VoucherID
FROM arrc_Voucher
WHERE ActivatedDT IS NULL
AND BalanceInit IS NULL
AND TypeFlag = 'V'
LIMIT 1 )
which I hoped would run the...
I have a query
SELECT A.a, A.b, A.c
FROM A
LEFT JOIN X ON A.a = X.x
WHERE X.x IS NULL
which finds entries in table A which have no corresponding entry in table X. How can I insert the results of this query into table X? If I had only a few entries I would do
INSERT INTO X(xa, xb, xc)
VALUES ('a1', 'b1', 'c1'), ('a2', 'b2', 'c2')
...
So far I have this query
SELECT
COUNT(f.code_id) as item_count,
f.code_desc
FROM
foo f
INNER JOIN foohistory fh ON f.history_id = fh.history_id
WHERE
MONTH(fh.create_dt) = 6
AND YEAR(fh.create_dr) = 2010
GROUP BY
f.code_desc
UNION ALL
SELECT
COUNT(b.code_id) as item_count,
b.code_desc
FROM ...
$sql="SELECT * FROM Reg_Stud WHERE Username='$var1' AND RegID=$var2 ";
this is the code...
i tried the input
Username =anything' OR 'x'='x
ID =12 or 1=1
no sign of sql injection...but when i just give the 1st argument and end it by commenting the rest...it gives sql error i.e anything' OR 'x'='x;--
...
Hi everyone, we are having an issue searching in the ContribContent Function. The StaticContent works fine, but the system will not search for CC.
The issue is this stored procedure is meant to search for content on an informational website there are three datatables involved:
StaticContent (written by our content
team),
ContribCo...
I have table sort of like
Name |DateOfEvent|EventType
----------------------------------
Smith |10/1/2005 |New
Thomas |1/1/2002 |Updated
Johnson |6/1/2002 |New
Smith |7/1/2008 |Updated
Smith |7/1/2000 |New
I want to return rows where the event is say New and the date is before a row with the same name bu...
Why would these queries return difference results:
SELECT *
FROM ProjectStatus PS
WHERE 0 = (SELECT COUNT(*)
FROM Project P
WHERE P.ProjectStatusKey = PS.ProjectStatusKey)
SELECT *
FROM ProjectStatus PS
WHERE PS.ProjectStatusKey NOT IN (SELECT P.ProjectStatusKey
...
Hi,
Currently I am dealing with a large dataset and some queries are executing several hours. In the meantime I am doing other things. In order to use time efficiently I have been thinking about implementing the logic to send email or SMS message after the query is complete so I can analyze the data.
I know how to do it by writing cust...
I need to get the words in a text field and make some updates with those words, for example:
original data
words | other field | another field
---------------------------------------------
white | |
some words | |
some other w | |
desired result
words | other...
On our production server, for some reason at specific amount of time, thread count goes over and over to the certain point that though CPU Utilization is normal(30-50%), but the query starting to run slow we so lot more blocking statements.
I am not sure where to look at it, basically when our site runs normally, the thread count is aro...
I use a cursor to iterate through quite a big table. For each row I check if value from one column exists in other.
If the value exists, I would like to increase value column in that other table.
If not, I would like to insert there new row with value set to 1.
I check "if exists" by:
IF (SELECT COUNT(*) FROM otherTabe WHERE... > 1)
...
I'm using following code to restore databases,
void Restore(string ConnectionString, string DatabaseFullPath, string backUpPath)
{
string sRestore =
"USE [master] RESTORE DATABASE [" + DatabaseFullPath + "] FROM DISK = N'" + backUpPath + "' WITH FILE = 1, NOUNLOAD, STATS = 10";
using (SqlConnection con = new SqlConne...
I have an integer column which I would like to add a foreign key constraint to. Only problem is if that column does not have/need a value, by default MySQL puts in a '0' value. This obviously breaks the foreign key constraint as there is no record in the primary table with a PK of 0.
How can I overcome this problem?
...
I'm totally new to ajax, but pretty good with PHP. I have a PHP page which currently refreshes every 2 minutes because it has to check for new data in the sql database. It's pretty annoying if you're using it and it keeps refreshing. The database is updated about 3 times a day, but what is shown on that page needs to be kept current with...
I have two tables.
products
id title image_ids
---------------------
1 myproduct 1,2,3
images
id title file_name
-------------------------
1 myimage myimage.jpg
2 myimage2 myimage2.jpg
3 myimage3 myimage3.jpg
I want to query so that the names of the images are concatenated into a single field for each prod...
Given the following sample table schema
Customer Table
CustID
1
2
3
Invoice Table
CustID InvoiceID
1 10
1 20
1 30
2 10
2 20
3 10
3 30
The objective is to select all customers who have an InvoiceID value of 10 and 20 (not OR). So, in this example customers w/ CustID=1 and 2 would be return...
Ok, I think I might be overlooking something obvious/simple here... but I need to write a query that returns only records that match multiple criteria on the same column...
My table is a very simple linking setup for applying flags to a user ...
ID contactid flag flag_type
-----------------------------------
118 99 ...
The SQL wildcards "%" and "_" are well documented and widely known. However as w3schools explains, there are also "charlist" style wildcards for matching a single character within or outside a given range, for example to find all the people called Carl but not those called Earl:
select * from Person where FirstName like '[A-D]arl'
......