I want to update a field if a field is blank.
I use the sql:
Update myTable set myField="abc" where (myField='')
But if the field is null, it will not be updated.
How can I do?Use IS NULL:
UPDATE myTable
SET myField = 'abc'
WHERE myField IS NULL
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"ad" <flying@.wfes.tcc.edu.tw> wrote in message
news:uUf4HVTfGHA.1324@.TK2MSFTNGP04.phx.gbl...
>I want to update a field if a field is blank.
> I use the sql:
> Update myTable set myField="abc" where (myField='')
> But if the field is null, it will not be updated.
> How can I do?
>|||"ad" <flying@.wfes.tcc.edu.tw> wrote
>I want to update a field if a field is blank.
> I use the sql:
> Update myTable set myField="abc" where (myField='')
> But if the field is null, it will not be updated.
> How can I do?
UPDATE myTable SET myField="abc" where myField='' OR myField is NULL
Bye, Anatoli
Showing posts with label abc. Show all posts
Showing posts with label abc. Show all posts
Wednesday, March 21, 2012
How to determinate a filed is empty
I want to update a field if a field is blank.
I use the sql:
Update myTable set myField="abc" where (myField='')
But if the field is null, it will not be updated.
How can I do?Use IS NULL:
UPDATE myTable
SET myField = 'abc'
WHERE myField IS NULL
--
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"ad" <flying@.wfes.tcc.edu.tw> wrote in message
news:uUf4HVTfGHA.1324@.TK2MSFTNGP04.phx.gbl...
>I want to update a field if a field is blank.
> I use the sql:
> Update myTable set myField="abc" where (myField='')
> But if the field is null, it will not be updated.
> How can I do?
>|||"ad" <flying@.wfes.tcc.edu.tw> wrote
>I want to update a field if a field is blank.
> I use the sql:
> Update myTable set myField="abc" where (myField='')
> But if the field is null, it will not be updated.
> How can I do?
UPDATE myTable SET myField="abc" where myField='' OR myField is NULL
Bye, Anatolisql
I use the sql:
Update myTable set myField="abc" where (myField='')
But if the field is null, it will not be updated.
How can I do?Use IS NULL:
UPDATE myTable
SET myField = 'abc'
WHERE myField IS NULL
--
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"ad" <flying@.wfes.tcc.edu.tw> wrote in message
news:uUf4HVTfGHA.1324@.TK2MSFTNGP04.phx.gbl...
>I want to update a field if a field is blank.
> I use the sql:
> Update myTable set myField="abc" where (myField='')
> But if the field is null, it will not be updated.
> How can I do?
>|||"ad" <flying@.wfes.tcc.edu.tw> wrote
>I want to update a field if a field is blank.
> I use the sql:
> Update myTable set myField="abc" where (myField='')
> But if the field is null, it will not be updated.
> How can I do?
UPDATE myTable SET myField="abc" where myField='' OR myField is NULL
Bye, Anatolisql
Monday, March 19, 2012
how to design a thorough test plan?
I am going to handle a test to a list of querys to find their efficency(spending of time)
here is my test plan:
there are query ABC..., and insert all querys into a table called querytbl;
open a cursor for all records from querytbl;
fetch next query from cursor;
while @.@.fetchstatus = 0
begin
exec query for 3 times and calculate average spending of time;
fetch next query from cursor;
end
...
Is there any better test plan?(just test spending of time)
or test tools?One of the things I think you would want to include is the changing of parameter data (if applicable).
by that I mean that...
select * from tblMyTest where MyID = 12345
might return a lot faster then
select * from tblMyTest where MyID = 54321
depending on how the tables have been constructed.
You probably want to test with different levels of data as well eg, 10000 record, 1000000 records etc.
What exactly are your trying to prove by your testing? Performance obviously, but are you also stress testing, load testing and durability testing, all of which are performance related.
HTH.|||The main purpose of the test plan is to compare perfomance of the same querys to different databases which have same data but different Logical/phsical structure, or to compare performance of different versions of the same query to same database.
---may call it "test different structure's performance"?
we do that because we want to get a general contractive performance report of all querys or versions when we want make some change to databases or querys, that'll help us to decide whether to apply the change.|||Okie, well in that case one of the things you probably want to include in your testing is how the query performs when other activities are taking place on the database tables that the query is referencing.
You may find that despite the fact that 70% or the time the 3 seconds query is faster, 30% of the time the query take 10 seconds longer because of the locking that is involved in the query.|||thanks! Actually All querys is executed in sequence in a batch,and there is only one batch running,we will stop other clients also,so I think In that case wonnt occur a lock.
one thing I am not sure is that whether a query will run faster or later if the query was run in different order in sequence?|||I can't think of any reason why it would,... but you might want to try it just to make sure...|||thanks for advises!
here is my test plan:
there are query ABC..., and insert all querys into a table called querytbl;
open a cursor for all records from querytbl;
fetch next query from cursor;
while @.@.fetchstatus = 0
begin
exec query for 3 times and calculate average spending of time;
fetch next query from cursor;
end
...
Is there any better test plan?(just test spending of time)
or test tools?One of the things I think you would want to include is the changing of parameter data (if applicable).
by that I mean that...
select * from tblMyTest where MyID = 12345
might return a lot faster then
select * from tblMyTest where MyID = 54321
depending on how the tables have been constructed.
You probably want to test with different levels of data as well eg, 10000 record, 1000000 records etc.
What exactly are your trying to prove by your testing? Performance obviously, but are you also stress testing, load testing and durability testing, all of which are performance related.
HTH.|||The main purpose of the test plan is to compare perfomance of the same querys to different databases which have same data but different Logical/phsical structure, or to compare performance of different versions of the same query to same database.
---may call it "test different structure's performance"?
we do that because we want to get a general contractive performance report of all querys or versions when we want make some change to databases or querys, that'll help us to decide whether to apply the change.|||Okie, well in that case one of the things you probably want to include in your testing is how the query performs when other activities are taking place on the database tables that the query is referencing.
You may find that despite the fact that 70% or the time the 3 seconds query is faster, 30% of the time the query take 10 seconds longer because of the locking that is involved in the query.|||thanks! Actually All querys is executed in sequence in a batch,and there is only one batch running,we will stop other clients also,so I think In that case wonnt occur a lock.
one thing I am not sure is that whether a query will run faster or later if the query was run in different order in sequence?|||I can't think of any reason why it would,... but you might want to try it just to make sure...|||thanks for advises!
Sunday, February 19, 2012
How to Delete ?
hi,
How to delete the following repeated data ?
my table :
Name Salary
--
Abc 20000
Abc 10000
CDE 01000
XYZ 12000
VID 30233
XYZ 40000
from the above table I want to delete repeated record 'Abc' and XYZ so that I should have the following records
Name Salary
--
Abc 20000
CDE 01000
XYZ 12000
VID 30233
Is it possible ?
Adv. thanks
bye
muralidharan T RYou need to be specific about which rows you wish to delete. If, for example, you want to delete all but the highest salary for each name:
delete from myTable
where Salary < (
select max(Salary) from myTable as T2
where T2.Salary > myTable.Salary
)
Steve Kass
Drew University
SQL Server MVP
Subscribe to:
Posts (Atom)