|
Test270307 wrote: when i run this statement that have some problems
That's a bit vague. What sort of problems?
Test270307 wrote: select * from tablea where
convert(datetime,OrderDate,101) >= (CONVERT(datetime,'26/03/2006',101)) AND
convert(datetime,OrderDate,101) <= (CONVERT(datetime,'27/04/2007',101))
Why are you doing all these conversions?
SELECT *
FROM TableA
WHERE OrderDate >= '2006-03-26'
AND OrderDate <= '2007-04-27'
When writing a date in SQL always use ISO format. That way you don't have to worry about cultural differences and your code will work anywhere.
|
|
|
|
|
sorry dear,
ur select statement does not return any rows.
in my select statement problems was:
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."
|
|
|
|
|
Test270307 wrote: ur select statement does not return any rows
Then perhaps OrderDate was in an incorrect type. If you are going to store dates in the database then store them as a SMALLDATETIME or a DATETIME . Do not store them as anything else unless you have an exceptionally good reason.
|
|
|
|
|
convert function's style 101 represents mm/dd/yy
your dates are in the format dd/mm/yyyy
use 103 for the same like ....
select * from tablea where
convert(datetime,OrderDate,103) >= (CONVERT(datetime,'26/03/2006',103)) AND
convert(datetime,OrderDate,103) <= (CONVERT(datetime,'27/04/2007',103))
Regards
KP
|
|
|
|
|
|
1
101
U.S.
mm/dd/yyyy
2
102
ANSI
yy.mm.dd
3
103
British/French
dd/mm/yy
Best Regards,
Chetan Patel
|
|
|
|
|
When you try to start Enterprise Manager of SQL server 2000, you get the following error message:
Snap-in failed to initialize.
Name: Not available
CLSID: {A841B6C2-7577-11D0-BB1F-00A0C922E79C}.
Earlier it was running perfectly alright. but for installing report service feature i upgrade sql2000 with service pack 3. after running setupsql.exe . it was shwing message like you should now backup your master and msdb database since this installation has update their content.
please help
thanks
regards
imran khan
|
|
|
|
|
Hi all,
How to delete duplicate Records in a table in SQLSERVER.
|
|
|
|
|
hi,
suppose col001 of table1 is the duplicated values.then the query
"select col001 from table1 group by col001 having count(col001)>1" will get all the
duplicate values so,
the below query will delete all the duplicated records.
"delete from table1
where col001 in (
select col001 from table1 group by col001 having count(col001)>1)"
regards
Jijo
jijo jose
|
|
|
|
|
Hi jijo jose,
Thanks for your response, but your solution deletes all records which are duplicate.even table does n't contain one value.
i want only delete duplicated records other than first value'
ex:
Sample Table Contains records are
sno sname
10 XXX
10 XXX
10 XXX
20 YYY
20 YYY
But after deletion of duplicate records i want records in table like this : sno sname
10 XXX
20 YYY
|
|
|
|
|
in continuation to my earlier solution....
select * from tblA where newcol IN (select min(newcol) from tblA group by sno having count(*) > 1)
should give first occurance of the each duplicate row.
Note :
newcol is the new identity colum
Regards
KP
|
|
|
|
|
hi,
I thought, you wanted to delete all the dubplicated one including original,
Then do this in your query analyser.........
1 st step
----------
alter table table1 add [id] int identity
2nd step
----------
delete from table1
where [id]
not in
(select min([id]) from table1 group by col001)
it will delete all the duplicate records from table1
regards
Jijo
-- modified at 9:36 Thursday 29th March, 2007
jijo jose
|
|
|
|
|
Add new column to the table and make it IDENTITY
so that each row can be identified Uniquely.
Regards
KP
|
|
|
|
|
You can use the temp table, put the only exist records into the temp table then you can delete the original table's records use the condition with the information of the temp table.
onestone
|
|
|
|
|
I have write a Strore Procedure with Encryption.
for Exmaple
alter Proc GetAll
with encryption
as
select * from test1
after completing SP Encryption.
I am not able to again modify My Store Procedure.
please help me.
Pavan Pareta
|
|
|
|
|
|
|
This is the accepted wisdom, but as with a lot of things that are accepted wisdom, it's not always true. Take a quick search on Google for decrypt Sql Server procedure, and you get numerous hits - some of which tell you how to decrypt procs. I've provided a link to one above.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have a table with a parent-child relationship in a MySQL database:
id
parent_id - points to id
other columns
I can easily extract all rows belonging to a particular parent. For example:
SELECT * FROM table WHERE parent_id=5
What I'm trying to do is extend this to not only get all rows belonging to a particular parent, but also get a count of each row's children (the grandchildren). I don't need any further generations. Other than retrieving the children and iterating through the rows and fetching the counts seperatley, I've been getting into a good muddle with joins and self-referential joins.
I'm hoping that some kind soul has a few suggestions!
|
|
|
|
|
This seems to work on my system (not MySQL).
SELECT * , (SELECT COUNT(*) FROM tblTasks WHERE parentTaskID=T.taskID)
FROM tblTasks AS T
WHERE T.parentTaskID=5;
Don't know whether MySQL will support the (SELECT ...).
Hope this helps.
|
|
|
|
|
That is perfect, thank you! And a whole lot simpler than my left joins
|
|
|
|
|
hello All dear,
I want to create job which sends email every 10 minute by retreiving fldEmail[email id] from table.
Develop2Program & Program2Develop
|
|
|
|
|
Navneet Hegde wrote: I want to create job which sends email every 10 minute
Using what you will send mail ? procedure ?
|
|
|
|
|
Hi dear,
I have a table consisting name and dateofBirth and email
now i want to create job that send's email to particular name on that date
Develop2Program & Program2Develop
|
|
|
|
|
for your job to be done you need a continuous scanning of your database table.......
you can do two things....
1. write a program for scanning your database every 10 minutes and expose your program as Windows Service ....the application will start as soon as your OS boots
or
2.write an application where you have to set up a Timer control to scan your database....make its interval to 10 minutes(interval=1000 means 1 second)...here you have to manually start your application unlike Windows Service ... or if it is a EXE file you can have it in your Start-up folder.......
Tirtha
"A man can ride on your back only when it is bent....."
|
|
|
|