November 1, 2006 at 11:06 am
There is anyway to do this running a single statment??
I need return the data like this:
counter Clientname
1 a
2 b
3 c
4 d
I have the clientname but I don't have the counter, How do I add this running a single script?
thanks
November 1, 2006 at 11:22 am
Why can't you use the application to display the row count?
November 1, 2006 at 11:44 am
this statement is from a view
November 1, 2006 at 11:49 am
And the view is only used on the server???
Can you give more details on what you are trying to accomplish, it would greatly help us provide the best solution.
November 1, 2006 at 11:51 am
I need a primary key on that view and the 2 tables involved there is no primary key, and I don't know how to do that.
November 1, 2006 at 12:05 pm
Again WHY????
Explain from A to Z what you need to do. There are way too many possibilities for me to start answering that question.
November 1, 2006 at 12:20 pm
that view provide details of the invoices, but the invoice table doesn't have a primary key, the application do not accept it, I try to modify and I shut down the company, so the problem is on a grid of asp.net if I click details it keep saying that I need a primary key to view the details, so I;m trying to come up with a solution for that.
hope this help you understanding my dilema
November 1, 2006 at 12:24 pm
and the original table is on AS400, I create that view using the OPENQUERY script, and I cannot change nothing on AS400
November 1, 2006 at 12:25 pm
Yes it does. But just creating a fake primary key on a view will not fix the problem. You need to create a primary key on the table(s) displayed in the datagrid. Otherwise you won't be able to do anything (with almost any tools for that matter).
If you need help fixing the design, I suggest you start a new thread and post the link to it in a new post in this thread (get most exposure).
November 1, 2006 at 2:29 pm
This might help you (SQL Server)
DECLARE @tbl TABLE (C VARCHAR(10))
INSERT INTO @tbl VALUES ('zzz')
INSERT INTO @tbl VALUES ('abc')
INSERT INTO @tbl VALUES ('abc')
INSERT INTO @tbl VALUES ('xxx')
INSERT INTO @tbl VALUES ('rtt')
INSERT INTO @tbl VALUES ('www')
INSERT INTO @tbl VALUES ('ccc')
SELECT T2.C,(SELECT COUNT(1) FROM (SELECT DISTINCT C FROM @tbl) AS T1 WHERE T1.C <= T2.C) AS UniqueId
FROM (SELECT DISTINCT C FROM @tbl) AS T2
ORDER BY 2
November 3, 2006 at 6:56 am
Wouldn't that be what the invoice number is for?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply