|
If Dat is date time format in your table then use following query
SELECT Dat
FROM dbo.tblkmreading
WHERE convert(varchar,Dat,103) = convert(varchar,GETDATE(),103)
If Dat is varchar in your table then use following query
SELECT Dat
FROM dbo.tblkmreading
WHERE convert(varchar,convert(datetime,Dat),103) = convert(varchar,GETDATE(),103)
smile
|
|
|
|
|
iam using oracle 10g and iam getting this problem.plz tell me steps that how could i solve this problem
ORA-12528: TNS:listener: all appropriate instances are blocking new connections
|
|
|
|
|
Hai,
I am hari,
I have a .MDF file, i want to restore this file into sqlserver 2005. How to restore this file give me clear process.....urgent please
thanks
pinna
|
|
|
|
|
Right click on "Databases" and select "Attach". Follow instructions from there on.
|
|
|
|
|
Hai,
Thanks for your reply its working
Thanks
pinna
|
|
|
|
|
please i need help
i have teble withe the flowing colums (slotid,sectionid)
the primery key is bothe i have the sectionid only
and i want to update the slotid withe diffrent values for the same section
i use vb.net and i do not now how i spend 2 week to fand slotion please helpe if you can i use diffrent ways
|
|
|
|
|
Hi,
I have a datatable with 3 expression column bind to datagridview with a bindingsource but the column are not displayed in the datagridview.
when i debug, it was throwing a StronglyTypedException and the innerexception is InvalidCastException "can not convert dbnull to decimal".
Please help.
Thanks in Advance
Lookman
|
|
|
|
|
this question isnt about SQL, however if you are adding rows through SQLDataReader then you will need to check the column weather its null or not, if not then add
use this for checking null value :
DR.IsDBNull( <Column index> )
hope it will help
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
hi iam getting error 01033 errror and oracle is not started..will u give help in this regard thanks in advance
|
|
|
|
|
Can you give more details on the error. Also which operating system you are using and which version of Oracle etc.
Thanks
|
|
|
|
|
Hi Guys,
I tries to look around but I could not find an answer for this question. I need to run an SQl Query which retuns me the highest Unique Value and the lowest Unique value from the same column. For example. Lets say the column name is itemPrice, and has the following values: 10, 10, 11, 12, 12, 13, 14, 14 respectively. How can I get the 11 and 13 as the result of my query. I have tried DISTINCT, MIN, MAX and HAVING but to no avail. I am using SQL Server 2000.
If anyone can help, I would really be grateful.
Thanking in Anticiption.
Regards
Ali
|
|
|
|
|
Look at my solution below. I have created a temp table to depict your scenario. The query in bold is the one you need.
Explanation: I first selected unique values from the table using group by clause, then I just picked the min/max ones
Create table #MyTable
(
ItemPrice int
)
insert into #MyTable values(10)
insert into #MyTable values(10)
insert into #MyTable values(11)
insert into #MyTable values(12)
insert into #MyTable values(12)
insert into #MyTable values(13)
insert into #MyTable values(14)
insert into #MyTable values(14)
select * from #MyTable
Select min(ItemPrice) as MinUniquePrice, max(ItemPrice) as MaxUniquePrice
From
( select ItemPrice, Count(*) as ItemPriceCount
from #Mytable
group by ItemPrice
Having Count(*) = 1
) as MyTableWithUniqueItemPrices
drop table #MyTable
Happy querying,
Mehroz
modified on Sunday, March 30, 2008 5:18 AM
|
|
|
|
|
Thanks Guys!
That was really helpfull.
Regards.
|
|
|
|
|
select itemPrice from Table1<br />
where <br />
(select count(i1.itemprice) from Table1 as i1 where i1.itemprice=Table1.itemprice)=1
I Love SQL
|
|
|
|
|
Hi - I'm having trouble running a sql script with "GO" using DbCommand...
sql scripts looks like this:
<br />
declare EmpCur cursor for (<br />
select * from employee where ...<br />
)<br />
GO << This go leads to error when run by DbCommand (Although NO error when run on ASE isql -- against Sybase)<br />
... more processing ...<br />
GO<br />
Now, the code is like this:
DataSet oDataSet = new DataSet(strName);<br />
DbProviderFactory oDbProviderFactory = null;<br />
DbDataAdapter oAdapter = null;<br />
DbCommand oCmd = null;<br />
DbConnection oConn = null;<br />
<br />
oDbProviderFactory = CDataUtil.GetConnectionFactory(strProvider);<br />
oConn = oDbProviderFactory.CreateConnection();<br />
oConn.ConnectionString = strConnectionString;<br />
<br />
oCmd = oDbProviderFactory.CreateCommand();<br />
oCmd.CommandText = m_Cmd.RenderCommand(null); <br />
oCmd.Connection = oConn;<br />
<br />
oAdapter = oDbProviderFactory.CreateDataAdapter();<br />
oAdapter.SelectCommand = oCmd;<br />
<br />
oConn.Open();<br />
oAdapter.Fill(oDataSet, strName);
Error message is like this:
2008-03-28 17:53:20,875 [1] ERROR XXXComponent - SQL command failed.<br />
Message: ERROR [42000] [MERANT][ODBC Sybase driver][SQL Server]Incorrect<br />
syntax near 'go'.
devy
|
|
|
|
|
GO is not a SQL statement. Rather, it is, by convention, a separator which tells the script processor that this is the end of a batch: it should send what it's read so far to the database, wait for a response, then proceed with the next set of statements up to the next GO (or end of file).
You should split your script at GO statements.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Mike Dimmick wrote:
You should split your script at GO statements.
Thanks - multiple sql scripts? And multiple Cmd.Execute?.. hum
my scripts looks like this, not sure if I can really "split"...
<br />
declare EmpCur cursor for (select * from Emp where ...}<br />
go<br />
... processing ...<br />
fetch EmpCur into @empId ...<br />
while (@@sqlstatus=0)<br />
begin<br />
fetch EmpCur into @empId ...<br />
... some processing ...<br />
insert into #tmp (empId, salary) (@empId, @salary)<br />
end<br />
<br />
select * from #tmp<br />
go
As you can see, declare cursor and the rest of the script must be separated by GO.
devy
|
|
|
|
|
You don't need the GO statement after declaring the cursor. By doing this, your first statement gets compiled into its own batch and is executed independently from the rest of the code. You don't want to do this. The one GO statement at the end is sufficient.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
o I tested the sql script on ASE isql (Sybase version of SQL's "Query Analyzer ") - it inisists "Declare cursor" be in a separate batch (therefore the GO that comes after it).
With Cmd.Execute you don't need to GO?
Thanks!!
devy
|
|
|
|
|
Hi - I've tried, got the following error after removing GO after DECLARE CURSOR statement:
Message: ERROR [HY000] [MERANT][ODBC Sybase driver][SQL Server]DECLARE CURSOR must be the only statement in a query batch.
If I *need* cursor, what are my options? Can we have GO in stored proc? (wrap sql statement by stored proc?)
devy
|
|
|
|
|
Hi every body!
I have a data base to store a large number of records and I want an Unique ID for each of them, so I used an UniqueIdentifier field, but the problem is when I delete a record, as you know, the identifier is not reordered automatically, so what should I do?
by the way, as I told I have many records to save. How can I prevent data from overflowing?
thanks for any help.
|
|
|
|
|
Is it necessary for the IDs to be contiguous? They'll still be unique, even if a record is deleted.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
infact no!
but because there are many deletion operations in data base and there are a large number of records, so the ID value grows too fast to the maximum value it can accept.
|
|
|
|
|
You probably shouldn't be using an IDENTITY column then.
Have a look at this article[^] about created custom auto-generated sequences.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi
I wrote one stored procedure it’s returning two parameters. How to get the two output parameters retuned by SP .
|
|
|
|