I'd like to check if there is anything to return given a number to check against, and if that query returns no entries, increase the number until an entry is reached and display that entry. Currently, the code looks like this :
SELECT *
FROM news
WHERE DATEDIFF(day, date, getdate() ) <= #url.d#
ORDER BY date desc
where #u...
Hello. I currently am working on a legacy application and have inherited some shady SQL with it. The project has never been put into production, but now is on it's way. During intial testing I found a bug. The application calls a stored procedure that calls many other stored procedures, creates cursors, loops through cursors, and many ot...
Is there a faster way to select the distinct count of users from a table? Perhaps using row_number, partitioning, or cross apply?
I just can't think of it right now.
Example:
Table UsageLog
UserId Date StoreNumber
Alice 200901 342
Alice 200902 333
Alice 200902 112
Bob 200901 112
Bob 200...
There's a stored procedure called "cnt_insertContestEntry" in my company's database. I'm new to database naming conventions. What could CNT possibly mean? Contest? i could ask my co-workers but i don't want to look dumb :p.
...
I've run across something that's bugging me just enough that I wanted to come here and seek out a sort of "best practice" type of advice from you guys (et gals)
I have a table in my model, let's call it prospect. Two separate external systems can provide an update for rows in this table, but only as a "status" of that record in those r...
I am looking for an alternative to TOAD on Linux. I have Oracle SQL Developer and a VM running TOAD but there are still too many features in TOAD that are not present in other tools. Is there any tool (price is not an issue) that is superior or equivalent to TOAD's features which runs on Linux and is not so damn buggy?
I also tried squ...
I want to executing a select statement in SSIS, but this select statement takes a parameter from another component, and the column of this select statement must be used as inputs to other components.
For example:
select id from myTable where name = (column from a previous component).
And the "id" content of the above select statement...
NO MySQL answers please!
The basic query is as follows (assume A is Key)
INSERT INTO destination (A,B,C)
SELECT a1,b1,c1
FROM source
WHERE (selectconditions) ;
Source contains many records that may or may not already be in destination, which means that the insert will fail as soon as a duplicate record is encountered.
Desired Behav...
I have a log that is really huge. (millions of rows)
LogTable
-------
ID
DATE
BASEURL
QUERYSTRING
USER
REFERRER
USERAGENT
SERVER
I want to slim this table down by normalizing the data. (slim the size)
I know! I know! A log should be a super-fast insert. On the other hand, the log table is so huge, the maintenance plan i...
I'm running the following SAS command:
Proc SQL;
Delete From Server003.CustomerList;
Quit;
Which is taking over 8 minutes... when it takes only a few seconds to read that file. What could be cause a delete to take so long and what can I do to make it go faster?
(I do not have access to drop the table, so I can only delete all rows)
...
Hi SQL gurus,
I need a query which can do the following operation.
I have a table with 2 columns
ID Values
1 1
1 2
1 3
1 4
2 2
2 5
2 6
if you see for ID 1 I have 1,2,3 and 4 as values and for ID 2 I have 2, 5 and 6.
I want to write a query which return the following
1(-)
4(-)
5(+)
6(+)
mean 1 and 4 are deleted and 5...
How do I get a WPF DataGrid to save changes back to the database?
I've data-bound my DataGrid control to a DataTable object, and populated that table with a very simple SELECT query that retrieves some basic information. The data shows up just fine in the control.
But when I use the control to edit the data, the changes are not pus...
Suppose that I have a table like:
class Ticker(Entity):
ticker = Field(String(7))
tsdata = OneToMany('TimeSeriesData')
staticdata = OneToMany('StaticData')
How would I query it so that it returns a set of Ticker.ticker?
I dig into the doc and seems like select() is the way to go. However I am not too familiar with the sql...
Hi,
I have this SQL query about getting the 5 events today:
SELECT n.nid, n.type, n.title, nr.body, nr.teaser, FROM_UNIXTIME(e.event_start) start_date, FROM_UNIXTIME(e.event_end) end_date
FROM node n
LEFT JOIN event e ON n.nid = e.nid
LEFT JOIN node_revisions nr ON nr.nid = e.nid
WHERE n.`type` = 'event'
AND NOW() BETWEEN FROM_UNIXTIME...
Using ANSI sql, how can I make query that
returns (row count, tablename) for every
table in the database ?
Thanks
Viki
...
Hi,
Currenlty I am using lot of inner join's(around 7) in my sp, does it have any impact on sp perfomance. does left outer join gives better perfomance then inner join.
one more thing if i m joining two tables a and b which has column id and id1, both r not nullable. i suppose here i can go for inner join as these columns r indexed.
...
table1:
col1 | col2
-------------
0 value1
1 value1
2 value1
0 value2
1 value2
2 value3
primary key is col1 and col2 together
table2:
col1 | col3
-------------
0 name1
1 name2
2 name3
primary key is col1.
col1 in table1 is referring to col1 in table2.
I need a mysql query that goe...
So, what I intended to do is to fetch a list of entries/posts with their category and user details, AND each of its total published comments. (entries, categories, users, and comments are separate tables)
This query below fetches the records fine, but it seems to skip those entries with no comments. As far as I can see, the JOINs are go...
Hi guys, i can't do a relative simple update query in access or sql server.
My simple task is: adding 1 to the current value of a column.
I'm using this syntax:
UPDATE MyTable SET ColumnA = ColumnA + 1 WHERE MyPrimaryKey= 100
But it does't work.
Someone can help me ?
Thanks bye!
...
Hi,
I'm trying to update a column in a database, but the column needs to be specified at runtime. For example, given the table:
| PKEY | ColumnA | ColumnB | ColumnC |
I want to write an stored procedure that will update a given column per PKEY. Such as:
updateColumn(pkey, columnName, Value);
This could easily be done using java/JDBC...