Say i am inserting the data into the database using bulk insert that is from asp.net to sol 2008.Now i Want to Validate the data How can i do that.Pls Help
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well for the most part your staging table’s design should be such that it won’t allow nulls where they should not be and the data types of the fields should be the types you expect. So say a field is a datetime then you won’t be able to insert any data expect data that is a datetime type. Similarly if a field is defined to be an int then the data can’t be a string type etc.
Try and use the feature/capabilities of the database to the extent possible by defining the correct datatypes for your fields. If any additional validations need to be done then you can run some stored procedure that does the other validations after import has finished.
Further, triggers on your destination table could help with ensuring valid data too.
For “data already exists” depending on what you want to do, you could use the MERGE statement to insert the data into the destination. The MERGE statement will allow you to ignore duplicates or update them (maybe some field’s values have changed and you need to new values to be updated).