|
You reckon? How exactly?
Regards,
Rob Philpott.
|
|
|
|
|
Something like this:
create table #X
(
C char(1)
)
insert into #X values ('A')
insert into #X values ('B')
insert into #X values ('C')
declare @z as varchar(2000)
set @z = ''
select @z = @z + C from #X
select @z
drop table #x
yields: ABC
Regards,
Rob Philpott.
|
|
|
|
|
Thank u verymuch it worked fine...
|
|
|
|
|
Is it possible to call a web service from Stored Procedure (Sql Server 2000),
If so how can we achieve this?
Thanks In Advance
|
|
|
|
|
vamsimohan21 wrote: Is it possible to call a web service from Stored Procedure (Sql Server 2000)
One way could be to create a program that calls the web service and use for example xp_cmdshell to call this program.
|
|
|
|
|
Mika Wendelius wrote: xp_cmdshell
Not recommended because this opens a high-risk security hole. IMHO, xp_cmdshell should be avoided at all costs.
|
|
|
|
|
Dave Kreskowiak wrote: Not recommended because this opens a high-risk security hole
True in many cases, but with Sql Server 2000 that was the only way that came in mind.
|
|
|
|
|
Its not a Good idea. Why Dont you call a Stored a Stored Procedure from a Web Service?
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
I have Table1 in Db Ms Access connection to VB2005
the Table has these columns A,B,C,D,F,G,H.. the typed of H is Date/time and the Typed of D is number and other columns is Text
I tried this Sql and it succeed with me.
Select Last( F),Last( G), SUM(D), A,B,C FROM Table1 Group by A, B, C
I want to make modification on that sql by define that row not by Last, but by MAX(H), or Order By H DESC
it's mean if the Table like this:
A :: B :: C :: D :: F :: G :: H
xxx :: yyy :: zzz :: 111 :: fff :: ggg ::2 Dec 08
xxx :: yyy :: zzz :: 222 :: rrr :: sss :: 1 Dec 08
x99 :: y99 :: z99 :: 432 :: uuu :: vvv :: 3 Dec 08
the result will be like this
A :: B :: C :: D :: F :: G
xxx :: yyy :: zzz :: 333 :: fff :: ggg
x99 :: y99 :: z99 :: 432 :: uuu :: vvv
|
|
|
|
|
did you try
Order by max(H) desc
Or
name the colum max(h) DateOrder
Order by DateOrder Desc
One of them may work in Access. Make sure that H is a date field NOT varchar.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes I tried but it is only work alone not with group
it's mean If I used like this
Select A,B,C.... From Table1 ORDER BY H DESC
It will works.
But If I tried to used in that Select
Select F,G,ORDER BY H DESC SUM(D), A,B,C From Table1 Group by A,B,C
it will not works
my problem is I don't know how to select the F,G in that Sql ORDER BY H DESC.
|
|
|
|
|
I have an email addresses from different employee and I only want to get the character before the @ sign, how can we do it in SQL?
I have tried the substring but it didnt work since the length of email add varies.
ex. MSantos@yahoo.com
CSanBeda@hotmail.com
Aaloya@gmail.com
I want to get the character before @ sign result should be
MSantos
CSanBeda
Aaloya
Thanks
Dabsukol
|
|
|
|
|
You can use CHARINDEX , like:
select substring('MSantos@yahoo.com', 1, charindex('@', 'MSantos@yahoo.com') - 1)
|
|
|
|
|
select substring(columnname, 1, charindex('@', columnname) - 1) from tablename
Do good and have good.
|
|
|
|
|
Probably a dumb question, but I can't figure this out.
Suppose I have 2 tables:
ORDERS(id,cust_id,date,price)
CUSTOMERS(cust_id,name)
I want to know how much money the customer #3 spent, and how many orders he did, okay:
SELECT COUNT(*), SUM(price)
FROM orders
WHERE cust_id=3
So far so good, now I want to know this, but I want to narrow it down to the latest 50 orders he did (or to the latest x orders if x < 50), how can I do that?
SELECT COUNT(*), SUM(price)
WHERE cust_id=3
ORDER BY date DESC
LIMIT 50
doesn't work, because there's still only 1 row returned. I'm a bit clueless
Thanks for your help!
|
|
|
|
|
Limit doesn't work because you are actually groupping everything into a single row. If you want to restrict the data that goes into the group operation, you have to do it in where or for example use inline views.
If you want to use where condition, it could be something like:
SELECT COUNT(*), SUM(price)
FROM Orders o1
WHERE cust_id=3
AND 50 <= (select count(*)
from Orders o2
where o2.cust_id = o1.cust_id
and o2.date < o1.date)
|
|
|
|
|
I see. Is subquerying the only solution? I'm not sure this is going to be run very fast.
|
|
|
|
|
Tony_P wrote: Is subquerying the only solution
No it's not. I think there are several ways.
Depending on your indexing an inline view may be faster. Then it would be something like:
SELECT COUNT(*), SUM(price)
FROM (SELECT TOP 50 Price
FROM Orders
WHERE cust_id=3
ORDER BY date DESC) tableAlias
Check the execution plan to see which one is better in your case. Additionally add relevant indexes if you need.
|
|
|
|
|
Ha right I like this solution. I'm going to benchmark both and see how it goes. Thank you!
|
|
|
|
|
|
|
What's in ad.InsertCommand property? That should contain the insert statement to use.
|
|
|
|
|
Can you give me an example
|
|
|
|
|
Example
hatan86 wrote: OleDbDataAdapter ad;
You have a variable named ad which is an instance of OleDbDataAdapter in your class. When you execute the Update method, you should have an insert statement in ad.InsertCommand property.
hatan86 wrote: OleDbException was unhandled
Syntax error in INSERT INTO statement
I've checked it and I can't find any syntax errors in it
You posted that you have checked the syntax of the insert command but have not found anything wrong in it. However, the insert statement is not visible in your post. Which statement did you check?
|
|
|
|
|
Hi to all,
I am working on a web project.The concept is based on online shopping cart.Please reply so that I can explain my problem.
thanx....
|
|
|
|