I am getting Incorrect syntax near the keyword 'select' after executing the following code.
declare @c int
SELECT @c = COUNT(*)
FROM (select id, max(date_stored)
from table B
INNER JOIN table P ON B.id = P.id
where id = 3)
select @c
I want to select total no of records having max stored dates in database. Can ...
I have to make a manual calculation of the next run date for a job, can you help me?
...
Table1
ID | WorkTime
-----------------
001 | 10:50:00
001 | 00:00:00
002 | ....
WorkTime Datatype is *varchar(.
SELECT ID,
CONVERT(varchar(10), TotalSeconds1 / 3600) + ':' + RIGHT('00' + CONVERT(varchar(2), (TotalSeconds1 - TotalSeconds1 / 3600 * 3600) / 60), 2) + ':' + RIGHT('00' + CONVERT(varchar(2), TotalSeconds1 - (T...
I have a schema like :
employees (eno, ename, zip, hdate)
customers (cno, cnmae, street, zip, phone)
zipcodes (zip, city)
where zip is pk in zipcodes and fk in other tables.
I have to write an update query which updates all the occurence of zipcode 4994 to 1234 throughout the database.
update zipcodes,customers,employees
...
Greeting People,
I'm trying to retrieve records from table by knowing the date in column contains date and time.
Suppose I have table called t1 which contains only two column name and date respectively.
The data stored in column date like this 8/3/2010 12:34:20 PM.
I want to retrieve this record by this query for example (note I don'...
If I have the following master-detail relationship:
owner_tbl auto_tbl
--------- --------
owner ---> owner
auto
year
And I have the following table data:
owner_tbl auto_tbl
--------- --------
john john, corvette, 1968
john, prius, 2008
james james, f-150,...
When should I consider representing the primary-key as classes?
Should we only represent primary keys as classes when a table uses composite-key?
For example:
public class PrimaryKey
{ ... ... ...}
Then
private PrimaryKey _parentID;
public PrimaryKey ParentID
{
get { return _parentID; }
...
Relevant Tables
#One#
+----------+ +--------------+
|Quotations| ---> |PurchaseOrders|
+----------+ | +--------------+
<One> | <Many> |
| v #Many#
| +-----------+ +------------+
v |Quot...
Hello :)
I've got a little problem with a query which I create in the Visual Studio Designer.
I need a query with a lot of 'OR'-clauses for the same column.
I found the operator 'IN', but I don't know how to use that in the Visual Studio Designer:
Example IN:
SELECT EmployeeID, FirstName, LastName, HireDate, City
FROM Employees
WHER...
I have 2 tables:
Table A: code | name
Table B: barcode | name
Table B has full barcode and name, Table A has only code.
I need to run update query that fill name in Table A.
I tried something like:
update A set name = (select top 1 Name from B where B.Code = mid(A.Barcode,1,8))
but it doesn't work.
...
I have a table with 3 fields:
ID (not unique, not primary key)
timestamp
marker
I want to get the last entry for every distinct ID, but when I doSELECT ID, max(timestamp) from table GROUP BY IDthe marker field is wrong.
I have another table with the following fields:
ID (unique, primary key)
lat
lng
I would like to perform the s...
Hey guys
I've been stuck with this simple Sql query for last 3 hours and my mind is drawing blank.
I have a User table that captures name user_id etc
Then I have a friends table that captures who is friend of whom and their status
User
user_id
name
Friend
friend_id
user_id
user_friend_id
status (accepeted,pending etc)
What I want ...
I'm not too good with SQL and I know there's probably a much more efficient way to accomplish what I'm doing here, so any help would be much appreciated. Thanks in advance for your input!
I'm writing a short program for the local school high school. At this school, juniors and seniors who have driver's licenses and cars can opt to drive...
I have the two following tables (with some sample datas)
LOGS:
ID | SETID | DATE
========================
1 | 1 | 2010-02-25
2 | 2 | 2010-02-25
3 | 1 | 2010-02-26
4 | 2 | 2010-02-26
5 | 1 | 2010-02-27
6 | 2 | 2010-02-27
7 | 1 | 2010-02-28
8 | 2 | 2010-02-28
9 | 1 | 2010-03-01
ST...
I have a column whose value is a json array. For example:
[{"att1": "1", "att2": "2"}, {"att1": "3", "att2": "4"}, {"att1": "5", "att2": "6"}]
What i would like is to provide a view where each element of the json array is transformed into a row and the attributes of each json object into columns. Keep in mind that the json array doesn...
I am facing the following design/implementation dilemma.
I have a class Customer which is below with getters and setters. I would like to insert the value of the Customer into a "Customer" table of a database. But Customer has an address which is of type "Address". How do I go about inserting this field into the database?(I am using sqli...
I have an SQL statement where I would like to get data of 1200 ep_codes by making use of IN clause. When I include more than 1000 ep_codes inside IN clause, Oracle says I'm not allowed to do that. To overcome this, I tried to change the SQL code as follows:
SELECT period, ...
FROM my_view
WHERE period = '200912'
...
AND...
Has anybody managed to get the ".NET Data Provider for SqlServer" to actually work within perfmon.exe.
I have a .NET app that uses nhibernate to interact with sql server 2005 db. All I want to do is to view the NumberOfActiveConnectionPools, NumberOfActiveConnections and the NumberOfFreeConnections within perfmon.exe
Can somebody expl...
Select top 1 from <tablename>
what is hql query for the above ?
...
When designing a stock management database system for sales and purchases what would be the best way to store the various taxes and other such amounts?
A few of the fields that could be saved are:
Unit price excluding tax
Unit price including tax
Tax per item
Total excluding tax (rounded to 2 decimals)
Total including tax (rounded to ...