View Single Post
  #1 (permalink)  
Old August 11th, 2008, 10:03 PM
Andraw Andraw is offline
Friend of Wrox
Join Date: Jan 2005
Location: Houston, TX, USA.
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Default Check value while insert in stored procedure


I create stored procedure inside it I will read a text file and insert each row into a table.

For example the table is as the following:
ID (primary key), lName, fName, age, address.............,

I create a cursor then fetch data to @ID, @lName, @fName, @age, @adress, then:

Insert into xxxTable(ID, lName, fName, age,address) Values (@ID, @lName, @fName, @age, @address)

But I want to check data before insert, for example, if @address = '', I wish to insert NULL, otherwise, insert @address, what is the easy way to do it? because I have 100 lines to insert, and each line has 65 fields, so I want to put the data checking inside the insert statement, is it possible?

in case there is ' char in address, is there some function like REPLACE in sp so I can replace ' to ''.



Reply With Quote