|
Hi,
Thanks for the reply.
It is SQL 2000 / 7.0
Any other optimal solution
A moment of silence please. A programmer's best friend has passed beyond that great exception in the sky.... - Mark Conger on "The coffee machine has died"
|
|
|
|
|
Well, you could always try something like this:
insert into table1(...)
select @id, @col2, @col3
from table1 where not exists (select id from table1 where id = @id)
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
Personally, in this case I'd use an Identity column for the primary key, and put the date information in another column defaulted to get the date (DEFAULT GETDATE()). I'm not sure what having the date as part of the primary key is buying you.
Scot
|
|
|
|
|
How can i insert the char " ' " into my sql Statement so that the SQL server 2000 take it by using VB.net 2005
|
|
|
|
|
Replace ' with ''
str.replace("'","''");
|
|
|
|
|
WARNING: The original question could be a symptom of a security hole.
|
|
|
|
|
Thanx it solved the problem
|
|
|
|
|
Be very careful with his solution at it can hide security problems. It you want to reduce the risk of your database being attacked then I suggest you don't use that solution.
|
|
|
|
|
Colin Angus Mackay wrote: Be very careful with his solution at it can hide security problems.
Could you please explain this in detail ? I am not getting the problem about converting ' to ''
|
|
|
|
|
|
Pete O`Hanlon wrote: Colin wrote this article
Thanks for the plug.
|
|
|
|
|
Use parameterised queries.
For example:
INSERT INTO MyTable(Column1, Column2) VALUES(@value1, @value2);
cmd.Parameters.Add("@value1", someValue)
cmd.Parameters.Add("@value2", someOtherValue)
cmd.ExecuteNonQuery()
|
|
|
|
|
is the Select Top functionality or an alternative available in sql server 2000?
if I have this data...
100
200
330
445
665
887
999
...I know I can achieve it by ordering it and then using the if value > ALL ... but what if it is a lot more complicated than this?
thanks
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
joon_ wrote: is the Select Top functionality or an alternative available in sql server 2000?
Yes.
|
|
|
|
|
Which is it?
SELECT TOP didn't exist before 2005, did it..?
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
joon_ wrote: SELECT TOP didn't exist before 2005, did it..?
Yes, it did. TOP was introduced in SQL Server 2000
|
|
|
|
|
I found my problem, it seems that Select TOP has changed it's capabilities a lot in 2005, and this was the issue. Thanks.
On a sidenote, I'm sorry for the poor quality of some of my posts, but I'm really just trying to learn and help people at the same time. Thank you for remaining professional and not just breaking down all of my ideas because you think I'm an idiot.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
i am useing dbcomman connection to conect sql
when trying to connect through lan computer
show time out
hoe to over come
|
|
|
|
|
|
Increment the connection timeout of SQL server Connection properties.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
use CommandTimeout property of dbCommand to increase timeout time
DbCommand cmd = new DbCommand();
cmd.CommandTimeout = 60; // 60 secs timeout
|
|
|
|
|
Hi
I hava stored procedure that runs three different queries. Two of these queries involve selecting aggregate data. i have to join these three resultsets on a common field. How can i do this inside a stored procedure and then output the result of join to the caller.
Amna Ahmad
|
|
|
|
|
If all three queries have the same data layout, just use the UNION command.
(SELECT * FROM table WHERE [somefield] = 0)<br />
UNION<br />
(SELECT * FROM table WHERE [somefield] <> 0)
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
JOIN and UNION mean different things. The original poster did not supply enough information to decide that he really meant UNION . He also indicated the possibility of only one common column so UNION would not be the the answer in that situation.
|
|
|
|
|
amnaahmad wrote: i have to join these three resultsets on a common field
You could put the results of the three individual queries in a temp table, or table variable. You can then join on the three tables.
It is possible to do everything that you want in one query, but the query optimiser doesn't seem to be too good at joining subqueries - especially if there is a lot of source data before the aggregation is done.
If you need help with the JOIN itself then can you supply more information about how the result sets are related.
|
|
|
|