Wednesday, March 21, 2012

REPLACE ALL

What is the SQL equivalent to a REPLACE ALL command in VFP?
I found this in the help section:
SELECT REPLACE('abcdefghicde','cde','xxx')
GO
Is this the full syntax and where would I use this command, I tried in the
EM but it doesn't seem to work.Preacher Man wrote:
> What is the SQL equivalent to a REPLACE ALL command in VFP?
> I found this in the help section:
> SELECT REPLACE('abcdefghicde','cde','xxx')
> GO
> Is this the full syntax and where would I use this command, I tried in the
> EM but it doesn't seem to work.
REPLACE ALL is basically similar to an UPDATE statement in SQL Server.
That is, both statements are used to update existing rows in a table.
For example:
UPDATE your_table
SET x = 123,
y = 456
WHERE z = 999 ;
You can find the full syntax in SQL Server Books Online.
David Portas
SQL Server MVP
--|||> What is the SQL equivalent to a REPLACE ALL command in VFP?
IIRC Replace in VFP is used to update table records. To update rows in a SQL
table, use the UPDATE statement.

> I found this in the help section:
> SELECT REPLACE('abcdefghicde','cde','xxx')
> GO
> Is this the full syntax and where would I use this command, I tried in the
> EM but it doesn't seem to work.
You found Replace function, which is not equivalent to VFP Replace command.
Dejan Sarka, SQL Server MVP
Mentor
www.SolidQualityLearning.com|||Lookup REPLACE is SQL Server Books Online.
Anith|||Ignore it :-(
Anith|||Can the Update command be used in the EM or the QA?
"Dejan Sarka" <dejan_please_reply_to_newsgroups.sarka@.avtenta.si> wrote in
message news:uBF72cHEGHA.2872@.TK2MSFTNGP14.phx.gbl...
> IIRC Replace in VFP is used to update table records. To update rows in a
> SQL table, use the UPDATE statement.
>
> You found Replace function, which is not equivalent to VFP Replace
> command.
> --
> Dejan Sarka, SQL Server MVP
> Mentor
> www.SolidQualityLearning.com
>|||"Preacher Man" <nospam> wrote in message
news:erpibxHEGHA.336@.TK2MSFTNGP14.phx.gbl...
> Can the Update command be used in the EM or the QA?
>
I recommend you use Query Analyzer. I think the only way to do it through EM
would be to create a proc containing the UPDATE statement. QA is the better
tool for SQL development.
David Portas
SQL Server MVP
--|||Yes, it can. I suggest you use QA. And use transactions - i.e. commit the
changes only after you've inspected the results and they are correct.
ML
http://milambda.blogspot.com/|||I use the REPLACE function in a UDF, to test an incoming string.
That allows me to test stuff in a SELECT with no UPDATE until after
inspection.
So, if the UDF (user defined function) is named dbo.udfGarbageRemoval, I can
use "inline" SQL to do the preliminary testing and inspection job.
For example:
SELECT udfGarbageRemoval(<fieldname>, <width> ), <field> FROM <table> ORDER
BY <blah>
This gives me immediate results for inspection with no transaction required.
I simply sort ASC and DESC on the field in question, do some Q&A and test
cases, and if the function works, then I do my update as follows:
UPDATE <table>
SET <field> = udfGarbageRemoval(<field>, <width> )
This techique if VERY fast, with no transaction nor update required until
after testing.
Functions are very easy to write in SQL, and blindingly fast.
John Smith
"Preacher Man" <nospam> wrote in message
news:erpibxHEGHA.336@.TK2MSFTNGP14.phx.gbl...
> Can the Update command be used in the EM or the QA?
> "Dejan Sarka" <dejan_please_reply_to_newsgroups.sarka@.avtenta.si> wrote in
> message news:uBF72cHEGHA.2872@.TK2MSFTNGP14.phx.gbl...
>

No comments:

Post a Comment