I am having data like below
Table1 data:
Attr1 Attr2
36 L
37 L
38 L
39 L
40 L
41 L
42 L
43 L
44 L
46 L
48 L
50 L
52 L
54 L
56 L
58 L
60 L
62 L
36 P
37 P
38 P
39 P
40 P
41 P
42 P
43 P
44 P
46 P
48 P
50 P
52 P
54 P
56 P
58 P
60 P
62 P
36 PL
37 PL
38 PL
39 PL
40 PL
41 PL
42 PL
43 PL
44 PL
46 PL
48 PL
50 PL
52 PL
54 PL
56 PL
58 PL
60 PL...
I have an on update trigger in SQL Server 2008. I only need to perform the trigger action if certain columns have been modified. Thus I'd like to check what has changed.
T-SQL offers an "if update( columnName )" construct. However, if many rows have been updated and only a single one of them has the particular column value changed "if...
I have two entities A and B that are related in a MxN relation through an intermediary table, thus making a total of three tables. My relation table R has non-nullable FK constraints on the other two tables.
I want to delete all entries from tables A and B and R where A obeys some constraint (I can supply the ids in A table for instance...
I'm really clueless as how to do this.
Say my table looks like so:
MESSAGES
- id
- date_posted
- content
How do I get the average time between postings? (date_posted)
...
I have a log table with the following format (and sample data):
date | time
2010/01/02 | 10:00
2010/01/02 | 13:00
2010/01/04 | 02:34
I want to make an SQL query that will retrieve results with the following format:
date1 | time1 | date2 | time2
2010/01/02 | 10:00 | 2010/01/02 | 13:00
2010/01/02 | 13:00 | 2010/01/04 |...
I'm trying to perform a CONTAINS query with multiple terms over multiple columns, like this:
SELECT ID
FROM Table
WHERE CONTAINS((Data1,Data2,Data3), '"foo" & "bag" & "weee"')
However, this query does not behave like I want it to: I want it to return all records for which all terms appear at least once in at least one of the columns, ...
is it possible to get MSSQL connection info?not onli SUSER_ID(), SUSER_NAME(), ORIGINAL_LOGIN(), BUT other like:
IP
Connection string
ect..
...
I am trying to populate a drop down list of SQLServers on a network using the osql -L command through Java. The user will then choose a server and type in a username and password. I also need to populate another list with the databases on that server. Any ideas on how I can implement that using java? If possible, please give java cod...
Hello,
I'm trying to create a view that displays events with start and end time. This view should be gathered from an existing table that only has an event time field and event type field.
So the current EventTable looks like this:
EventTime | BooleanField
------------------------------
1/1/2010 6:00AM 1
1/2/2010 6:00AM ...
All servers running SQL 2005
SQL server (NOLA) replicates to 35 remote locations (StoreXX).
Earlier this week, one publication started having problems connecting to 30 of the 35 remote locations, with an error of:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Date 2/4/2010 10:00:01 AM
Log Job History (NOLA-Closing_Balance-CB Defaults to Stores-...
We have SQL Server 2000 database with money data type columns and we have strange problem with numbers within money columns in which we store numbers with 2 decimal places. For o long time everything was OK. But now I see that in some rows where was number 47.22 is now number 47.2178. When i select CAST(COLUMN as CHAR) result is 47.22 bu...
Is it possible using nHibernate, or Entity Framework, or whatever, to generate the SQL necessary to INSERT or UPDATE an object I've mapped to a table? I'm looking at generating SQL scripts from these POCO classes instead of running directly against a database.
The idea here is I'm taking some 2000+ line SQL scripts and I've made a Pyt...
I am currently working on a PHP project with an Oracle database. To update a table, the php code I'm working with uses a SQL "MERGE INTO" method to loop through a table and see if values for multiple records exist in another table. If they don't exist yet, the values are inserted into my table. If the values already exist, nothing hap...
I heed some help constructing a SQL statment. Currently I have the following:
SELECT a, b, count(1)
FROM table
GROUP BY a, b
ORDER BY a asc, count(1) DESC
Each row displays the sum of all the unique B's within each grouping a and orders by A alphabetically and then by highest occurrence of B to the lowest. What I would actually lik...
Id Project_Id Activity_Time Username
1 100 2008-01-01 11:12:13 A
2 100 2008-01-01 00:00:00 B
3 500 2008-02-01 00:00:00 C
4 300 2008-02-03 00:00:00 D
5 500 2008-03-03 11:11:11 A
6 300 2008-04-04 00:00:00 D
...
I'm working on getting our system's java beans to be able to use the SQL IN clause when running queries down through the database, but am running into a perplexing problem.
I am build the SQL query for the PreparedStatement in the following generic pattern:
select [column names]
from [table name]
where [a column name] IN (?, ? , ?, .....
This might be long, but I want to explain my example
I got this Code:
#region [parent table]
DataTable dtParent = new DataTable();
DataColumn dc;
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.Int32");
dc.ColumnName = "Id";
dc.Unique = true;
dc.AutoIncre...
Hi, I have inhertited an legacy application, that I have little control over. I need to map a one to one relationship because "A user may have one of these, lets call them 'a Rejection', but not more than one" The data stored in the Rejection table is quite large.
Anyway, I have simplyfied this model, using cats, dogs and an owner. An ...
I have an sqlite table in my game that keeps track of scores. How do I make one of the columns track scores in ascending order instead of descending order?
...
I'm using MySQL's LOAD DATA LOCAL INFILE SQL statement to load data from an CSV file into an existing database table.
Here is an example SQL statement:
LOAD DATA LOCAL INFILE 'file.csv' INTO TABLE my_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(name, address, dateOfBirth)
The third column in the CSV that m...