In my TSQL script I have an IF THEN ELSE structure that checks if a column already exists.
If not it creates the column and updates it.
IF NOT EXISTS(
SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tableName' AND COLUMN_NAME = 'columnName'))
BEGIN
BEGIN TRANSACTION
ALTER TABLE tableName
ADD colu...
where i need to select char(253) and get ANSI character in Arabic collation dosent work
...
I'm using Pervasive SQL. I have the following UNION of mulitple SQL statements. Is there a way to clean this up, especially the Pay Date an the Loc No fields that are selected in each statement. Is there a way to pull this out and have only one place to need to change those two fields?
(
SELECT
'23400' as Gl_Number,
...
I am trying to implement hierarchyID in a table (dbo.[Message]) containing roughly 50,000 rows (will grow substantially in the future). However it takes 30-40 seconds to retrieve about 25 results.
The root node is a filler in order to provide uniqueness, therefor every subsequent row is a child of that dummy row.
I need to be able to ...
Hey guys,
I have 3 tables with a column in each which relates to one ID per row. I am looking for an sql statement query which will check all 3 tables for any rows in the last 24 hours (86400 seconds) i have stored timestamps in each tables under column time.
After I get this query I will be able to do the next step which is to then c...
hi,
my situation is the following: i have a datareader and loop over all records returned by a select statement and then call a function with a value from that row. but now i need to update a column in each row, after the function has been called.
using a separate update statement seems like a huge overkill. what's the best method to d...
Hibernate criteria, using DB2 dialect, generates the following sql with
composite keys in the IN clause, but DB2 answers that the query is incorrect:
select * from tableA where (x, y) IN ( ( 'x1', y1) )
but, DB2 throws this:
SQL0104N An unexpected token "," was found following ", y) in
( ('x1'".
Expected tokens may include: "+". S...
Hello All.
I have a sql query where I want to insert multiple rows in single query. so I used something like:
$sql = "INSERT INTO beautiful (name, age)
VALUES
('Helen', 24),
('Katrina', 21),
('Samia', 22),
('Hui Ling', 25),
('Yumie', 29)";
mysql_query( $sql, $conn );
The problem is when I execute this query, I want to ch...
I am having some trouble with the following queries originally done for some Access forms:
SELECT qry1.TCKYEAR AS Yr, COUNT(qry1.SID) AS STUDID, qry1.SID AS MID, table_tckt.tckt_tick_no
FROM table_tckt INNER JOIN qry1 ON table_tckt.tckt_SID = qry1.SID
GROUP BY qry1.TCKYEAR, qry1.SID, table_tckt.tckt_tick_no
HAVING (((table_tckt.tick_n...
Just doing a site which requires multiple items to be reordered by AJAX.
When I create a given object in the database, I want to set the position column to the value of the rows' primary key upon creation.
How would I do this please?
...
I have developed an application using VB.NET, Visual Studio 2008 and the SQL Server database. Now I want to ignore the database (it has 1 table as customer (name,password,hour,minute)) as I don't want my client to install SQL Server separately or other overheads.
I am planning to do the whole using file handling in VB.NET (manipulating ...
I'm not exactly positive how to word this for the sake of the title so please forgive me. Also I can't seem to figure out how to even google this question, so I'm hoping that I can get a lead in the right direction.
Part of my software(VB.NET App) requires the ability to access/read/write a shared network folder. I have an option for th...
I took over maintenance of a PHP app recently and I'm not super familiar with PHP but some of the things I've been seeing on the site are making me nervous that it could be vulnerable to a SQL injection attack.
For example, see how this code for logging into the administrative section works:
$password = md5(HASH_SALT . $_POST['logi...
I need to port this following from Oracle syntax to Postgresql.
Both FLO_END_DT and FLO_START_DATE are of type DATE in Oracle, and TIMESTAMP WITHOUT TIME ZONE in Postgresql:
SELECT TRUNC( TO_CHAR(ROUND(( FL.FLO_END_DT- FL.FLO_START_DT)* 24), '9999D99'), 2)
FROM FLOWS FL
I am not familiar enough with Oracle to know what it is tryin...
I've been very happily using PredicateBuilder but until now have only used it for queries with only either concatenated AND statements or OR statements. Now for the first time I need a pair of OR statements nested along with a some AND statements like this:
select x from Table1 where a = 1 AND b = 2 AND (z = 1 OR y = 2)
Using the docu...
Let's assume I have a database with two tables: categories and articles. Every article belongs to a category.
Now, let's assume I want to fetch the latest article of each category that fits a specific criteria (read: the article does). If it weren't for that extra criteria, I could just add a column called last_article_id or something s...
I am trying to format a date:
FORMAT(table.TCKT.TCKT_ISS_DATE, 'YYYY') AS TICKETYEAR
but I am getting the following error:
ORA-00904: "FORMAT": invalid identifier
Right now the date show the complete timestamp. Any suggestions on how to fix this problem, or any other way to format the date to just show the four digit year?
...
I’m in the process of cleaning up a database table. Due to the way some of the data needed to be processed, now I need to go back and perform a “reverse lookup” on the data. For example, a field for one of the records is set to “car” and I need to set that record’s tranportmode field to “1” (for “car”). The lookup tables are already crea...
I am attempting to calculate the miles per gallon for logged fuel full-ups. My table consists of the flowing:
FillUp(CarID, Date, ODReading, Gallons, StopGo, Highway, FillupID, MPG)
I want to subtract the ODReading from the previous record and divide gallons by this computed value.
How do I work between records to achieve this withi...
Let's say I have a table that has a varchar field. If I do an insert like this:
INSERT MyTable
SELECT N'the string goes here'
Is there any fundamental difference between that and:
INSERT MyTable
SELECT 'the string goes here'
My understanding was that you'd only have a problem if the string contained a Unicode character and th...