|
I think I *may* have found a better way. Go to SSMSE and use the wizard to create a new database and make it sql7.0 compatable. You'll find that choice under the select a page window (click the option page).
HTH.
Pictures of the menu available at the drive-thru
|
|
|
|
|
Hey, Thanks for your replies...
So I take it that I will need to install SSMSE? I don't recall seeing that anywhere after I installed studio 2005? If so, I will download it and run the wizard.
Thanks again,
Rashar
|
|
|
|
|
|
Hi
I have a data in sql table as
EventTypeID Content EventID
1 abc 1
2 gdfg 2
3 fdg 4
4 fgh 54
1 er 54
2 dfg 34
3 fgfdg 34
1 eert 45
2 dfg 4
The result i want is, when i fire a select query , the result should be IN THIS FORMAT like this
EventTypeID Content EventID
1 abc 1
2 gdfg 2
3 fdg 4
4 fgh 54
1 er 54
2 dfg 34
3 fgfdg 34
4 NULL NULL
1 eert 45
2 dfg 4
3 NULL NULL
4 NULL NULL
So which query will do this ?
|
|
|
|
|
Looks like you are missing a column. If you are trying to match sets of EventTypeIDs (1,2,3,4) you need to identify the sets some how. I can't see anything in your data that would indicate a relationship between the sets except order (which is unreliable and not guarenteed).
Go back to take a closer look at your design.
|
|
|
|
|
Select EventTypeID ,Content ,EventID from Tablename
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
Hi Sandeep,
Your reply is:
Select x.EventTypeId, z.Content, z.EventId from (Select distinct EventTypeId from tbl) x left join tbl z on x.EventTypeId=z.EventTypeId
This way you can get the expected result.
Best Regards,
Darpan Gogia
|
|
|
|
|
We're on the process of shifting from Single to Distributed Database.
We have a program (say Mainprogram) that updates the central database, specifically Table1.
Also, we have many existing little programs (say Subprogram1, Subprogram2, ..etc) that also updates the central database, also the Table1, just like the MainProgram. We need to resolve this in such a way that only one program will update the central database.
It is certain that the Mainprogram will only the one who will update the central database. How will our little programs handle this. These little programs need also to update the Table1 in central database.
Or is this OK? Please help. I dont know anything about DB. Im using Oracle 9+ and VC++ 6.0
|
|
|
|
|
Hi,
I have table like this
Name Age RolNo. Qty
A 1 2 3
B 1 2 3
C 2 4 5
D 2 9 2
E 2 4 1
F 3 3 4
G 4 5 5
H 4 4 4
NOW, I WANT THE FETCH RESULT AS (i,e First row of each group , GroupBy Age)
Name Age RolNo. Qty
A 1 2 3
C 2 4 5
F 3 3 4
G 4 5 5
What query i should write for this. which meets my requirement.
Thanx
sandeep
|
|
|
|
|
SELECT a.Name, a.Age, a.RolNo, a.Qty FROM Table1 AS a, (SELECT MIN(Name) AS MinName FROM Table1 GROUP BY Age) AS b WHERE a.Name=b.MinName
Is that right?
|
|
|
|
|
i face a problem converting varchar to datetime,the date is stored as char(10) and i need to compare it with a time. i use this stored procedure
CREATE PROCEDURE cst
@v datetime AS
select * from col
where CAST ( col AS DATETIME ) < @v
GO
and get this error when run this (exec cst '01/02/2006')
Server: Msg 242, Level 16, State 3, Procedure cst, Line 5
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
|
|
|
|
|
Do you have a table named col in your database that also has a column named col ?
What is the datatype of the col column?
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
EricDV wrote: Do you have a table named col in your database that also has a column named col?
yes i have.
the datatype of the col is char(10).and all its data like '01/02/2006'
what i want is to select recoreds less than eg. '01/01/2006'
|
|
|
|
|
Check your data in the col column.
You will get that error if there is a record that cannot be converted:
ie.
00/00/0000
01/01/0001
00/01/2000
01/00/2000
The error will not happen if all the data is valid.
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
is there any way to tell it the date format because all recored are in correct format . a datetimepicker was used to fill it
|
|
|
|
|
it is a better practice to use Convert instead of Cast
use it as follows
Convert(smalldatetime,'01/02/2006',103)
i think this will do your work
note u can change 103 to whatever format u are using
good luck
dsfds
|
|
|
|
|
Try changing your stored procedure to this:
CREATE PROCEDURE cst
@v datetime
AS
SELECT * FROM col WHERE CASE WHEN ISDATE(col)=1 THEN CAST ( col AS DATETIME ) ELSE @v END < @v
GO
I'm not sure why there is a problem with the CAST, but checking to make sure that the col ISDATE() will most likely avoid the problem. However, records that have a col column are not able to be converted will not be returned.
Does this help?
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
EricDV wrote: CREATE PROCEDURE cst @v datetimeASSELECT * FROM col WHERE CASE WHEN ISDATE(col)=1 THEN CAST ( col AS DATETIME ) ELSE @v END < @vGO
yes it work but i have just discovered that when it casts the it to datetime, it put it in the format mm/dd/yyyy.
is there anyway to let the format dd/mm/yyyy
thanks for your help
|
|
|
|
|
shabonaa wrote: is there anyway to let the format dd/mm/yyyy
Use the CONVERT function instead of CAST, but leave the rest of the proc the same.
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
the problem was that When the language is set to us_english, the default order for the date is (mdy). so when i declare @v datetime it consider that the order is (mdy) i used (SET DATEFORMAT dmy). and it worked good
CREATE PROCEDURE cst
@v char(10)
AS
SET DATEFORMAT dmy
SELECT * FROM col
WHERE CASE WHEN ISDATE(col)=1
THEN CAST ( col AS DATETIME )ELSE CAST ( @v AS DATETIME )
END < CAST ( @v AS DATETIME )
GO
thanks for all your help
|
|
|
|
|
Select Convert(smalldatetime,'01/02/2006',102)
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
Hi All,
Can't we use temporary table as part of the SHAPE command? I got the following error when I am trying to use. "[MERANT][ODBC Oracle 8 Driver][Oracle]ORA-00942: table or view does not exist". I will appreciate that if someone help me with this. My SQL goes like this.
SHAPE {SELECT * FROM PARENT }
APPEND ((SHAPE {SELECT * FROM CHILD }
APPEND ({SELECT * FROM GRANDCHILD,
(SELECT * FROM (Select * From ext_attr_val a Where upper(a.attribute_cd) = 'GET') get, (Select * From ext_attr_val b Where upper(b.attribute_cd) = 'SET') set Where get.seq = set.seq and get.c_seq = set.c_seq and get.t_seq = set.t_seq) temp
} Relate otc_trade_Seq to otc_trade_Seq, otc_ci_seq to otc_ci_seq) as adoBotRs) RELATE trade_seq to otc_trade_seq) as adoMidRs
Here get, set and temp are temporary tables.
|
|
|
|
|
Hi,
Excuse my newbian ways to the world of SQL. Thanks to Mike Ellison i have the following code working:
SELECT orderTableID, orderUserID, SUM(orderPrice) AS totalPrice FROM tbl_Orders WHERE orderPaid = true GROUP BY orderTableID, orderUserID
Which shows me the Table Number, Name, and Total order cost, of customers. However i really need to be able to adapt this to produce total costs by category for each user. Ive come up with some SQL but it creates a new line for each user and each category total.
What i really need is one statement that will give me the following format:
Table, Name, Drinks Total, Food Total, Total Cost<br />
Table, Name, Drinks Total, Food Total, Total Cost<br />
Table, Name, Drinks Total, Food Total, Total Cost<br />
Table, Name, Drinks Total, Food Total, Total Cost<br />
Table, Name, Drinks Total, Food Total, Total Cost
etc, whereby each customers order total(s) is display as one line.
Hope this makes sense, and that someone can help me sort tihs out.
Thanks in advance!
munklefish
|
|
|
|
|
We don't have enough information to answer this question. How is the 'Drinks' and 'Food' stored in your schema? Is 'Total Cost' a summation of these two?
|
|
|
|
|
Hi,
Ive tried my best to determine the SQL i need to match and retrieve data from two tables. Below is the SQL ive come up with so far but when i test it in Access, it gives me a non descriptive error.
Here is the code so far:
SELECT a.*, b.* FROM tbl_Payment AS a, (SUM (orderPrice) AS totalPrice FROM tbl_Orders, WHERE orderPaid = false AND orderTableID = '12' AND orderUserID = 'Healey') AS b WHERE a.paymentTable=b.orderTableID AND a.paymentTable = b.orderUserID
Can anyone help me sort this out. Basically i need to get all the data from one table and its corresponding data in a second table. If you could give me any help id really appreciate it.
Happy Easter!
Munklefish
|
|
|
|