Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure the way to go?

Status
Not open for further replies.

ninners

Programmer
Apr 22, 2003
10
US
I have a previously created table that is populated using a BULK insert from a user selected file. This table has only one field, a list of document numbers.
I need to go through this list/table where the number of records would vary between 200-500 items and check that the field is a valid number, no letters, spaces or strange non-numeric characters. The "valid" numbers would then be inserted into another table for further processing. The first option I thought of was pulling all the records down and using PHP/ASP some script to check for a valid number. Then I thought that might not be the best idea which brings me here. :)
My question is would it be better to create a stored procedure to do the checking and inserting? Going through record by record with a script seems like the hard way, but I am not sure. I have never created a SP from scratch only slightly modified them before so I could be getting into something much more difficult and beyond my skill level.
If SPs are the way to go could you point me in the direction of some good websites to help me get started?
Thanks!
 
Stored Procedures probably are the way to go.

I've never read a lot about stored procs, but this is by Ken Henderson, he is very good.


Hope this helps,

Alex

It's a magical time of year in Philadelphia. Eagles training camp marks the end of another brutal season of complaining about the Phillies.
 
I can think of few places wher a stored procedure is not the way to go, so I would guess that using a procedure in this case would be best.

Also, if I understand correctly what you sre attempting, the SQL is quite simple.

Look at BOL for ISNUMERIC There is a good explanation there

Then look at BOL for INSERT INTO

then use InsertInto combined with the SELECT ISNUMERIC(column) example and you are home free

I am big on BOL. I do feel the layout is a bit "goofy" until you get used to it, but getting used to BOL is a very good thing.

You can download it free from good ole Billy Boy's site.

Also you stated you are kne to T-SQL. I suggest the Sams book on SQL server as a good basic primer.

You will not become an expert (or even fair) from them, but they will help you gain a basic understanding you can build on.
 
Thanks for the quick replies! Could you post the SELECT ISNUMERIC(column) example that you mentioned? I am still trying to learn my way around BOL.

Thanks again!
 
Your update statement (or whatever type of statement you want to run) should be followed by this:

where isnumeric(fieldname) = 1 (for numeric)
where isnumeric(fieldname) = 0 (for non-numeric)

HTH,

Alex

It's a magical time of year in Philadelphia. Eagles training camp marks the end of another brutal season of complaining about the Phillies.
 
also look into the Exists clause. that used along with the above queries will give you the desired results...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top