|
Any trick of using Select TOP in dataset to datatable. I know that we can have a select TOP in the query but that is currently infeasible in my case since datasource does not support that. Also this is for .NET framework 1.1.
Any clues?
|
|
|
|
|
Hi Deepak,
u can use the following query to select teh datarows in f/w 1.1.
DataRow[] arrDRow = ds.Tables[0].Select("Top 10");
this returns an array of datarows with the criteria specified, which you can manipulate as required.
Let me know if that works.
Regards
Deepali
|
|
|
|
|
Missing operand after 10 operator
|
|
|
|
|
Hi All,
I have a question for you?
I have to pass 7 parameters to the procedure.
for some parameters i am not passing a value.
how to do this?
sivamyneni
|
|
|
|
|
You need to supply defaults for each of your optional parameters:
create procedure MyProc
@Param1 varchar(10) = null,
@Param2 int = null,
@Param3 date = null
as begin
set nocount on
--do stuff
return(0)
end
go
exec MyProc
exec MyProc 'hello', 123, '1 feb 2007'
exec MyProc 'world'
exec MyProc @Param3 = '1 feb 2007' Hope this helps.
Andy
|
|
|
|
|
Hi
I tried that one i am not getting proper result because none of my field contaains null value.so i am not getting the desired.
sivamyneni
|
|
|
|
|
Try this:
If Your procedure is like following:
ALTER PROCEDURE myProcedure<br />
@Param1 int = 0,<br />
@Param2 int = 0, <br />
@Param3 int,<br />
@Param4 int = 0,<br />
@Param5 int = 0, <br />
@Param6 int,<br />
@Param7 int<br />
<br />
<br />
AS<br />
<br />
<br />
-- Procedure code
In order to call it (say, from another sp):
exec myProcedure @Param3 = @PassedParam1, @Param6 = @PassedParam2, @Param7 = @PassedParam3
Note: Initialize parameters in the original procedure if you are not sure, the procedure will get those parameters passed to it. (In the case above, if you will not pass one of the @Param3, @Param6, or @Param7) the error will happen.
Hope that helps.
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
hi,
i need some help regarding data access from XML sent by web services.
I have a web service that sends out XML as its result, as below:
<?xml version="1.0" encoding="utf-16"?>
<Response webMethodId="GetUserListing">
<SecurityContext sessionId="154oe1upayjpnx55pg1f3r45" />
<Document>
<ArrayOfUsers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<User>
<UserId>32</UserId>
<Name>foxtrot</Name>
<Address>Suite 712</Address>
<Zip>12345</Zip>
< PhoneNumbers>
<string 111-111-1111/>
</PhoneNumbers>
<Emails>
<string>foo@foo.bar</string>
</Emails>
</User>
</ArrayOfUsers>
<TotalRecords>25</TotalRecords>
</Document>
</Response>
In the RDL file, the Query i specify is:
<Query>
<Method Namespace ="http://tempuri.org/" Name = "ProcessRequest" ></Method>
<SoapAction>http://tempuri.org/ProcessRequest</SoapAction>
</Query>
and the result i get is in a single line that says ProcessRequestResult, with the XML specified above in a single line. however, i need the result in a tabular form, which would give me records of different users, one below the other.
if i specify the <ElementPath> element for the query, i do not get any response at all.
The <ElementPath> element i specify is:
<ElementPath>Response{}/SecurityContext{}/Document{}/ArrayOfUser{}/User</ElementPath>
i need urgent help for this and any help would be appreciated.
Thanks in advance
Deepali
|
|
|
|
|
Hi
Can anyone help with an SQL statement im having problems with ?
i want to do something like the below
select date_in, type= CASE date_in
when datepart(hour,date_in) > 12 THEN 'Afternoon'
ELSE 'Morning'
END
from my_table
where date_in >='2007-2-1'
so it will return something like
2007-02-01 08:22:32.663 Morning
2007-02-01 09:22:32.773 Morning
2007-02-01 14:42:32.803 Afternoon
2007-02-01 15:56:32.803 Afternoon
however im getting an error thrown back at me when i try to execute it
Line 2: Incorrect syntax near '>'.
Any ideas ??
thanks
Simon
|
|
|
|
|
correct your query like this
select date_in, type= CASE
when datepart(hour,date_in) > 12 THEN 'Afternoon'
ELSE 'Morning'
END
from my_table
where date_in >='2007-2-1'
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
|
|
|
|
|
You do not have a BEGIN for the END specified below ELSE
Deepali
|
|
|
|
|
CASE has two syntaxes. You can either use it like a C/C++/C# switch or VB Select Case statement, where you specify an expression to be tested against multiple possibilities, or you can use it more like a multi-armed if statement, where you supply boolean expressions - the first one to evaluate to true is then returned.
The syntax for the first is:
CASE expression
WHEN value1 THEN result1
WHEN value2 THEN result2
ELSE defaultresult
END The syntax for the second:
CASE
WHEN booleanexpression1 THEN result1
WHEN booleanexpression2 THEN result2
ELSE defaultresult
END
|
|
|
|
|
Hello,
Is it better to use define data type in sql tables, What is advantage and disadvantage of user define data types ?
Regards,
S Kumar
|
|
|
|
|
I like defined data types. They are a great way to enforce standards. For instance, if I have a need for Name fields throughout the database and they are always going to be 30 characters then it is much better for me to be able to define a name data type and then use this wherever there is a Name field.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi John,
Thanks a lot for your reply.
Best Regards,
S Kumar
|
|
|
|
|
Hi,
I've heard that there is an sql helper file which has got all the stuff regarding the connectivity to the databse, like connectio, command objects....
Is there any any sort of refernce/link where i could get that?
Thanks!
Gautham
|
|
|
|
|
|
Which index is good to apply.clustered or nonclustered?
|
|
|
|
|
It really depends on the situation, as each type of index has its strengths and weaknesses. If you were offering a phone book, for instance, and wanted to have quick retrieval based on the surname then forename, then a clustered index is much better than an ordinary index because there is a great deal of internal sorting going on there. So searching on Smith John would quickly retrieve the Smiths and then fine filter from there to return the Johns.
The downside of the clustered index is the fact that everytime an insert occurs, then significant reordering needs to be done to guarantee that rows are kept adjacent. This means that clustered indexes can become a real performance hit in high-insert tables.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Generally it is best to have a clustered index defined on every SQL Server table - otherwise it is treated as a heap. By default SQL-Server creates clustered indexes for primary keys. The engine contains a specific optimisation that makes it efficient to have a clustered index that is based upon an incrementing identity column.
A clustered index contains the table's data in its leaf nodes, so the records are physically sorted - and so is ideal for "range" scans. The following scenario takes advantage of this:- A "Customer" table has a clustered primary key on "CustId".
- An "Invoice" table has a non-clustered primary key on "InvoiceId", and a unique clustered index on "CustId, InvoiceId".
It is now very efficient to join between the Customer and Invoice tables.
Another technique that may prove useful, is to define a non-clustered index, but include additional columns that you would not normally be searching upon. SQL-Server will automatically use the data from the index (and not attempt to read the table data) if all of the information it requires for a query is located in a suitable index. This is called "covering".
http://www.sql-server-performance.com/tips_performance.asp[^] contains a bunch of articles and tips that you may find useful.
|
|
|
|
|
Good points, but the OP never mentioned SQL Server . I'm not an expert in other databases, so I hope you can tell me is this the same with other engines?
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi Pete
I know that the following engines have clustered indexes:- Sybase (as you would expect because of SQL-Server's heritage).
- Informix had them back in 87.
- Oracle has Index Organized Tables (IOTs), which amounts to the same thing.
All of these conform broadly to the guidelines I provided earlier. If you google for "Clustered Index" then SQL-Server gives your the most hits.
The "covered" index thing has been supported by most high-end engines for many years. SQL Server 2005 has a new "include" clause for non-clustered indexes that is well worth checking-out. There are circumstances where this has better query performance than a clustered index.
On small databases there isn't much to be gained - so most of the lower league engines (MS-Access, etc) do not seem to support the concept. Interestingly, it looks like MySql supports them.
Regards
Andy
|
|
|
|
|
Andy
Thanks for that. Guess which database I specialise in . It's always good to find out how things work from somebody who knows about them.
Many thanks.
Pete
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
anujose wrote: Which index is good to apply.clustered or nonclustered?
If you are using SQL Server (and I presume any other type of database) you can only have one clustered index. A clustered index is where the actual rows are sorted in the order of the index. A non-clustered index means that a separate index is set up that points to the real rows.
|
|
|
|
|
Dear All,
I tried to get the views that are defined using a particular table name. Can any one give me the query for that? I already tried with user_views in the following way.
select view_name from user_views where text like '%tablename%';
The problem here is that the text column datatype is LONG. So I am getting inconsistent datatype err.
Thanks
Surendran
|
|
|
|