473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Regular Expression?


I need to remove all the [ and ] in every sql stmt where they are used
to close encircling numeric value, fyi, all these sql stmt are
converted from an Access db. For instance,
select *
from XYZtbl
where fieldA = [1] or fieldA = [2] or fieldA = [3]

to be
select *
from XYZtbl
where fieldA = 1 or fieldA = 2 or fieldA = 3

-- and of course I'd have written in as follows, but that's not
-- the point
select *
from XYZtbl
where fieldA IN (1,2,3)

Thanks.

Sep 6 '05 #1
5 1460
Hi

If you are generating these queries dynamically they should be removed in
the code that generates them.

You can not change the query once it has been sent to the server unless you
write your own driver, therefore you will have to change the source. You may
want to create stored procedures from these queries rather than use ad-hoc
queries.

John

"NickName" <da****@rock.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...

I need to remove all the [ and ] in every sql stmt where they are used
to close encircling numeric value, fyi, all these sql stmt are
converted from an Access db. For instance,
select *
from XYZtbl
where fieldA = [1] or fieldA = [2] or fieldA = [3]

to be
select *
from XYZtbl
where fieldA = 1 or fieldA = 2 or fieldA = 3

-- and of course I'd have written in as follows, but that's not
-- the point
select *
from XYZtbl
where fieldA IN (1,2,3)

Thanks.

Sep 6 '05 #2
On 5 Sep 2005 18:38:58 -0700, NickName wrote:

I need to remove all the [ and ] in every sql stmt where they are used
to close encircling numeric value, fyi, all these sql stmt are
converted from an Access db. For instance,
select *
from XYZtbl
where fieldA = [1] or fieldA = [2] or fieldA = [3]

to be
select *
from XYZtbl
where fieldA = 1 or fieldA = 2 or fieldA = 3

-- and of course I'd have written in as follows, but that's not
-- the point
select *
from XYZtbl
where fieldA IN (1,2,3)

Thanks.


Hi NickName,

Where are these queries stored?
SQL Server doesn't store actual queries - it accepts them, executes
them, then returns you the results.
On the other hand, the code for stored procedures, user-defined
functions and triggers is stored in SQL Server.

If you have your queries stored in files on your computer, check
www.tucows.com for a freeware or shareware GREP-like utility to quickly
make the change for you (but beware that you specify the regular
expression patterns in a way to prevent unwanted side-effects!!)

If this is code in stored procedures etc, then there is no easy way to
change it all at once. You'll either have to change the procedures one
by one (which is a good opportunity to bring them all in some change
control system), or investigate what went wrong on the conversion from
Access, fix that problem, then re-convert.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Sep 6 '05 #3
Hi Hugo,

These are 'saved' queries in Access I'm in the process of converting
them to either View or SP, and obviously SQL Server would accept
something like
select *
from XYZtbl
where fieldA = [1] or fieldA = [2] or fieldA = [3]

I thought about GREP but wanted to check if there's other option.

On Access conversion, it convert queries to virtual tables.

Thanks.

Don

Sep 6 '05 #4
"If you are generating these queries dynamically they should be removed
in
the code that generates them."
Exactly, that's what I wanted to do in the generation/conversion
process.

"You may
want to create stored procedures from these queries rather than use
ad-hoc
queries. "
Yes, either view or sp.

Thanks.

Sep 6 '05 #5
Hi

Then you should look at the search/replace functionality of a text editor or
even Query Analyser.

I have not come across this thing before in access queries, so I am not sure
why they are there.

John

"NickName" <da****@rock.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
"If you are generating these queries dynamically they should be removed
in
the code that generates them."
Exactly, that's what I wanted to do in the generation/conversion
process.
"You may
want to create stored procedures from these queries rather than use
ad-hoc
queries. "
Yes, either view or sp.

Thanks.

Sep 7 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
4
by: Buddy | last post by:
Can someone please show me how to create a regular expression to do the following My text is set to MyColumn{1, 100} Test I want a regular expression that sets the text to the following...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
11
by: Dimitris Georgakopuolos | last post by:
Hello, I have a text file that I load up to a string. The text includes certain expression like {firstName} or {userName} that I want to match and then replace with a new expression. However,...
3
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
9
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
1
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
1
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "":...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.