Validating SP Inputs

Sep 23, 2007

This question is rather open ended. Basically, I'm wondering the different approaches people use when validating input into a stored procedure. The rest of my post just describes a rather simple approach I'm using, and some ideas I have, but I'm eager to know what others are doing. So, if you'd like to comment on this, feel free to do so without reading the following.





I often find myself calling a stored procedure, and needing to validate some of the inputs before proceeding with the rest of the tasks. Such as, making sure a matching record isn't already in the database before adding a new record. Ideally, this sort of validation will report back to the user interface immediately, so that the user can get real-time response to their form input, instead of the all-too-common approach of redirecting to an error page if something goes wrong in the database transaction.

It's also convenient, at times (though perhaps not efficient in all cases) to let your database perform business rules validation of inputs (let the user interface make sure data types are valid, and such), so that you duplicate less code in the event that the stored procedure is called in more than one context.

To address these issues, I've taken to making two stored procedures instead of one. Let the stored procedure be called AddRecord. I'd create that, as well as the procedure named AddRecord_Validate, which would take identical inputs as AddRecord, whenever possible. Nearly the first thing done in AddRecord would be to execute AddRecord_Validate. The user interface would also call AddRecord_Validate, and return any validation errors to the user interface.

This seems rather convenient to me, in many cases, but often it doesn't work as well as I prefer. It's not uncommon for me to end up performing the same queries in the _Validate SP as I do in the parent SP. For example, let's say I'm passing a parameter that I use to look up a record I plan to edit. In my validation, I query the database to verify that the record is found. But in the parent SP, I run the same query again in order to get the stored ID of the record I need to edit. This ends up duplicating queries, making the pair of procedures less efficient on the whole, as well as introducing the likelihood of bugs when code changes in one of the SPs, but not the other.

So I've been brainstorming other approaches. The first idea is to execute a single stored procedure, but when I want to run it in "validation" mode, I simply rollback the transaction. This would let me know if the stored procedure would have run with the specified input, but won't ultimately change anything. Unfortunately, I see some badness in this, such as the entire SP perhaps taking a lot longer to execute that simple validation would have, and side-effects such as incrementing Sequences, or locking the database, and basically just doing a whole lot more work during validation than needs to be done.

The next idea was to require that the user specify the "run mode" via a parameter, either 'validate' or 'run'. Then, all of the validation would be performed at the top of the stored procedure, and a simple IF statement would exit the SP before actually making any changes if it's run in 'validate' mode. Otherwise, it will continue, and do the real work. The only real downside I see to this is forcing the developer to deal with an extra parameter. And, perhaps, it's not really a "relational" approach.

So, what do the rest of you do?

View 5 Replies


ADVERTISEMENT

Validating Inputs And Finding Patterns With PatIndex

Sep 5, 2007

---Checks that input only contains numbers
if PatIndex('%[^0-9]%','11') > 0
Begin
Print 'Not all numbers'
End
Else
Begin
Print 'All numbers'
End

---Checks that input only contains letters
if PatIndex('%[^a-z]%','aaaaa') > 0
Begin
Print 'Not all letters'
End
Else
Begin
Print 'All letters'
End


--Checking for mixed input
If PatIndex('%[^0-9][0-9]%','abc') > 0
Begin
Print 'Alpha numeric data'
End
Else
Begin
Print 'Either all numbers or all letters'
End

--Checks that value must start with a letter and a number
If PatIndex('[^0-9][0-9]%','A1anamwar11') > 0
Begin
Print 'Starts with a letter and a number'
End
Else
Begin
Print 'Does not start with a letter and a number'
End

--Checks that value must End with a letter and a number
If PatIndex('%[^0-9][0-9]','A1anamwar11a1') > 0
Begin
Print 'Ends with a letter and a number'
End
Else
Begin
Print 'Does not End with a letter and a number'
End


--Checks that value must Start with a letter and Ends with a number
If PatIndex('[^0-9]%[0-9]','namwar1') > 0
Begin
Print 'Starts with a letter and ends with a number'
End
Else
Begin
Print 'Does not start with a letter and ends with a number'
End

Namwar
<Link removed by georgev>

View 13 Replies View Related

Multiple Inputs In One Row

Oct 3, 2014

Is there anyway to get a sum of values from the below sample where Code=A?

Code1 Code2 Code3 Val1 Val2 Val3
A A B 1 5 8
B A B 5 6 2

Desired Result

Val = 12

View 1 Replies View Related

Multiple Inputs

Apr 1, 2008



I am sorry, This might sound very silly, but i am new here.
I have multiple excel files from which i need to draw data into one database table. Any thoughts?Any help will be appreciated

View 7 Replies View Related

Stored Procedure With Multiple Inputs

Aug 3, 1999

Hello.

I'm trying to write a generic Stored Procedure will select records with the following options.

1. Select XXX from theTable
Where ID = 1

2. Select XXX from theTable
Where ID = 1 or ID = 3 or ID = 4

The issues is that at run time the WHERE CLAUSE COULD CHANGE
(it could have multiple OR-d options)

Is there a way to pass a varChar argument like "Where ID=1 or ID =2"?
Thanks in advance!
-andy

View 2 Replies View Related

Date Inputs (UK Format) In SQL Svr 2000 With OLE DB

Jul 20, 2005

Hi all,I'm building an ASP app on a Windows 2000/IIS machine which interfaceswith our SQL Server 2000 database via OLE DB.Since we're based in the UK I want the users to be able to type indates in UK date format to input into the database. In EnterpriseManager on the SQL Server I can manually enter a record into a tableand just type in a UK date (MM/DD/YYYY e.g. 25/12/2004) and it acceptsit happily.However, if I enter the exact same record on the form on the web page,again using the UK date format, I get this back from the IIS box:HTTP 500.100 - Internal Server Error - ASP errorInternet Information ServicesTechnical Information (for support personnel)Error Type:Microsoft OLE DB Provider for SQL Server (0x80040E07)The conversion of a char data type to a datetime data type resultedin an out- of-range datetime value./ictest/eventadm.asp, line 78I'm assuming that despite SQL Server accepting the date in UK format,OLE DB will not. Can the OLE provider be configured to allow suchdate formats, either (I imagine) in the registry or by altering theconnection string?TIA,Niall

View 7 Replies View Related

Merge Join With Empty Inputs

May 25, 2006

Hi all,

Does anyone have suggestions for ways to deal with the chance that a merge join might receive empty inputs?

I've noticed that when this happens the transformation seems to hang. I changed the MaxBuffersPerInput to zero and this seems to cure the problem but I'm not sure it's the best way to deal with it.

Would it be a good idea to test the row counts with a conditional split before such a join?

Cheers,

Andrew

View 6 Replies View Related

CHECKSUM , Produces Same Hash For Two Different Inputs. Is This Right?

Jul 25, 2007

Hi,

We are using binary_checksum in some of instead of update trigger. The problem came into the knowledge when update falied without raising any error. We came to know after research that checksum returns same number for two different inputs and thats why update failed.

We are using following type of inside the trigger.



UPDATE [dbo].[Hospital]

SET

[HospitalID]= I.[HospitalID],

[Name]= I.[Name],

[HospitalNumber]= I.[HospitalNumber],

[ServerName] = I.[ServerName],

[IsAuthorized]= I.[IsAuthorized],

[IsAlertEnabled]= I.[IsAlertEnabled],

[AlertStartDate]= I.[AlertStartDate],

[AlertEndDate]= I.[AlertEndDate],

[IsTraining]= I.[IsTraining],

[TestMessageInterval]= I.[TestMessageInterval],

[DelayAlertTime]= I.[DelayAlertTime],

[IsDelayMessageAlert]= I.[IsDelayMessageAlert],

[IsTestMessageAlert]= I.[IsTestMessageAlert],

[IsUnAuthorizedMessageAlert]= I.[IsUnAuthorizedMessageAlert],

[IsWANDownAlert]= I.[IsWANDownAlert],

[IsWANUpAlert]= I.[IsWANUpAlert],

[CreateUserID]= Hospital.[CreateUserID],

[CreateWorkstationID]= Hospital.[CreateWorkstationID],

[CreateDate]= Hospital.[CreateDate] ,

/* record created date is never updated */

[ChangeUserID]= suser_name(),

[ChangeWorkstationID]= host_name(),

[ChangeDate]= getdate() ,

/* Updating the record modified field to now */

[CTSServerID]= I.[CTSServerID]

FROM inserted i

WHERE

i.[HospitalID]= Hospital.[HospitalID]

AND binary_checksum(

Hospital.[HospitalID],

Hospital.[Name],

Hospital.[HospitalNumber],

Hospital.[ServerName],

Hospital.[IsAuthorized],

Hospital.[IsAlertEnabled],

Hospital.[AlertStartDate],

Hospital.[AlertEndDate],

Hospital.[IsTraining],

Hospital.[TestMessageInterval],

Hospital.[DelayAlertTime],

Hospital.[IsDelayMessageAlert],

Hospital.[IsTestMessageAlert],

Hospital.[IsUnAuthorizedMessageAlert],

Hospital.[IsWANDownAlert],

Hospital.[IsWANUpAlert]) !=

binary_checksum(

I.[HospitalID],

I.[Name],

I.[HospitalNumber],

I.[ServerName],

I.[IsAuthorized],

I.[IsAlertEnabled],

I.[AlertStartDate],

I.[AlertEndDate],

I.[IsTraining],

I.[TestMessageInterval],

I.[DelayAlertTime],

I.[IsDelayMessageAlert],

I.[IsTestMessageAlert],

I.[IsUnAuthorizedMessageAlert],

I.[IsWANDownAlert],

I.[IsWANUpAlert]) ;





Here is the checksum example which produces same results for two different input.





DECLARE @V1 VARCHAR(10)

DECLARE @V2 VARCHAR(10)

SELECT @V1 = NULL, @V2=NULL

SELECT binary_checksum('KKK','San Jose','1418','1418SVR ',0,1,@V1,@V2,0,30,180,1,0,1,1,1),

binary_checksum('KKK','San Jose','1418','1418SVR ',1,1,@V1,@V2,0,30,180,1,1,1,1,1)



Lookat the two binary_checksum above, they are different and should not match, but they both return same value.



Can someone please provide some info on these.

View 4 Replies View Related

Need Inputs For The Datacenter Migration Project

Feb 5, 2008





Hi All,

We are going to migrate to new datacenter which will be starting in April this year and I am responsible for installation,configuration of sql servers in the new datacenter.

I have done couple of servers before but this time its like 60 sql servers and lot of applications depend on this. I would appriciate any inputs/tips/cautions/documentation/links which you think will help me in this.


Thanks in advance.

--Phani

View 4 Replies View Related

Task With Multiple Inputs Not Executed

Apr 26, 2007

I have modified my workflow to take conditional branch. The workflow terminates after the branched tasks finish without continueing to the next task no matter how I set the flow out condition. I found I have this problem when a task take more than one input. Does SSIS has a seeting for limiting the inputs to be taken?



Thanks in advance for the help!

View 3 Replies View Related

Multiple Inputs In Merge Join?

Nov 16, 2007

hi guys,
just wondering if there's a SSIS component out there some what similar to Merge join but can take up more than two inputs to join.

basically i have a big package with data sources coming from everywhere, they all have a unique column i can join on, so right now, i use merge join for every two sources, then join the output of that to another source so on and so forth. it would be easier if i can just join all of the sources in one component rather than putting a merge join for every single join. is there such a component out there, custom built maybe?

cheers

View 6 Replies View Related

Building Custom Component - Marking All Inputs

Feb 14, 2007

I have been building a custom component with the default GUI. I want to have all the input fields selected to be passed through to outputs without having to explicitly check each one in the GUI. Is there some method or property to set on the input to do this?

View 3 Replies View Related

Questions On Attributes Acting As Both Inputs And Predictive?

Apr 30, 2007

Hi, all experts here,

Thanks a lot for your kind attention.

I am having quesion about attributes acting as both inputs and predictive outputs in a mining models, I mean if we are going to predict the outputs, then I cant actually see the effects of themselves acting as inputs as well?

I dont really see through the points of it.

Could please any experts here shed me any light on it.

I am looking forward to hearing from you shortly and thanks a lot in advance.

With best regards,

Yours sincerely,

View 6 Replies View Related

SSIS Web Service Complex Type Inputs

May 21, 2007

Hi,

I am trying to make a call to a third-party web service in my SSIS package. The request has custom complex data type as the parameter. As has been pointed out in this forum before, the Web Service Task only lets you assign the outside parameter from a variable, not the internal parameters needed to create the complex data type.

To be more specific, the web service input wants a 'ContactSearchRequest' parameter. I can assign this from a variable. If I click on the 'value' field under the 'Input' section for the web service task, it shows me that the 'ContactSearchRequest' data type is made up of the following:

contactId - long
numResults - int
offset - int
passKey - string
searchParam - string
sortType - int

Unfortunately, I can't assign these internal parameters from a variable, at least not through the web service task interface.

My next thought was to create a variable of type 'object' and then set it in a script task prior to calling the web service task. However, I'm not sure exactly how to do this. How will my script know about the class definition of 'ContactSearchRequest'? Do I just create a class called 'ContactSearchRequest'?

I've used this same web service in a .NET C# project and after I imported the web service, visual studio knew all about the custom data types. How do I do something similar in SSIS?

Of course, the easiest solution would for Integration Service to allow me to set those internal parameters via variables, but we're apparently not there yet.

Any suggestions?

Thanks,
Trey

View 8 Replies View Related

Integration Services :: Component OLE DB Source Has No Inputs

Nov 12, 2015

I have a Data Flow Task. I have one "OLE DB Source" which gets my data from a SQL Server Database. I have a second "OLE DB Source" which uses DATEADD to derive a date qualifier that I would like to use as a date qualifier in my subsequent Excel spreadsheet...opting to use SQL Server and DATEADD rather than messing around with VB syntax to get the previous week date qualifier.I am trying to connect the flow from one OLE DB Source to the next OLE DB Source and get the error..Component OLE DB Source has no inputs, or all of its inputs are already connected to other outputs. You may be able to edit the component to add new inputs to it.Can't I connect two completely different and independent SQL Server queries using "OLE DB Source" within my Data Flow?

Is there any way to store my derived date from my second "OLE DB Source" to a variable so that I cana then use that as my date qualifier within my Excel destination?

View 6 Replies View Related

!!help!! How To Save User Inputs From Checkbox List To Database??

Dec 11, 2007

Hi,
 
I'm new to ASP.NET 2.0. I'll like to ask how do one save user input from txtbox, radiobttnlist or checkboxlist into database?
Im implementing a suvrey form here by the way.
 -any reference webs,
-any pointers from experts?
Thank you for your time in reading this email
 
Kayln

View 7 Replies View Related

Making A Form That Inputs Data In To My Database And Getting This Error...

Jan 5, 2008

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30456: 'InserParameters' is not a member of 'System.Web.UI.WebControls.SqlDataSource'.Source Error:





Line 15: registrationDataSource.InsertCommand = "INSERT TO Reputation (firstname, lastname)VALUES(@First Name, @Last Name)"
Line 16:
Line 17: registrationDataSource.InserParameters.Add("firstname", firstname.txt)
Line 18: registrationDataSource.InserParameters.Add("lastname", lastname.txt)
Line 19: Source File: C:UsersQaiphyx
eputationDefault.aspx.vb    Line: 17
Show Detailed Compiler Output:

View 1 Replies View Related

SQL 2012 :: Date Format In Text Column With Many Other Inputs

Feb 10, 2014

How to convert MM/YYYY to MM/DD/YYYY and also YYYY to 01/01/YYYY.

This column is text column and has many other inputs.

View 4 Replies View Related

T-SQL (SS2K8) :: Inserting Date Range Depending On Inputs

Mar 14, 2014

I'm trying to modify a date range, but it's much more complicated.

Let's say I have existing date ranges of:

BlockIDStartDateEndDateActive
182013-12-31 00:00:002013-12-31 00:00:001
192014-01-01 00:00:002014-01-23 00:00:001
202014-01-24 00:00:002014-01-25 00:00:001
212014-01-26 00:00:002014-02-04 00:00:001
222014-02-05 00:00:002014-02-13 00:00:001
232014-02-14 00:00:002014-02-15 00:00:001

I've created code that will do the following (depending on the inputs):

1) Create new start and end dates
2) Inactivate obsolete date ranges

View 8 Replies View Related

Custom Data Flow Transformation - Predefined Inputs

May 16, 2008

Hi,

I've created my own custom data flow transformation task (using C#) that
will parse a fullname and output the various name parts. In the
ProvideComponentProperties method, I create 5 output columns (prefix, first, middle,
last, and suffix). In the ProcessInput method, I parse the input and add the
name parts to the buffer. The bad thing is that I€™m making an assumption on
the position of the Full Name input column within the buffer.

I would like the €œuser€? to be able to map their "full name" input column to a known Full Name column so I don€™t have to make any assumptions. This is the first
SSIS task I€™ve tried to create and I haven€™t been able to find very many
examples online.

Any help is greatly appreciated!

Thank you,

Marshall

View 1 Replies View Related

How Do You Use Data From A Select Statement As Inputs For A Store Procedure?

Dec 13, 2007

How do you use data from a select statement as inputs for a store procedure?

e.g.





Code Block

Select FirstName, LastName from Student where Grade = 'A'

And I want to use all the FirstName and LastName as inputs for this store procedure





Code Block

Exec StudentOfTheMonth @FirstName = FirstName, @LastName = LastName
Thanks

View 21 Replies View Related

Integration Services :: Handling Variable Column Inputs

May 18, 2015

I receive a data feed from a third party in a pipe delimited file.  From time to time, they add a column at the end.  I would like my ssis package to continue to process the data even if they add a column with out it breaking. How best do I handle this situation?

View 6 Replies View Related

Integration Services :: Why Merge Transformation Need To Sorted Inputs

Jul 16, 2015

Why Merge Transformation Need to Sorted Inputs?

View 4 Replies View Related

Validating Data In Sql Using C#

Nov 19, 2007

Hello All again,
I have another question, I would like to validate the data in a sql table before my code runs and inserts duplicate information. Can anyone help out with this via example?

View 2 Replies View Related

Validating 2 Table's Plz Help

Jul 30, 2004

I have one table called product 1 and the second table is called product 2 i have DirNo, ProdNo, UpdCode and BranchOffice as fields i whant to loop trought every record in table product 1 and check in table product 2 if the record is the same and exist i f it does go to next record, if not delete the record in product 1 and move to the next record and so on. could someone please help me. iam very new at this.
thanks

View 4 Replies View Related

VALIDATING CONSTRAINTS

Apr 14, 2008



hello

i am using visual studio 2008 to create an inventory management system and i am having trouble checking for a constraint violation. i have a partnumber colum in the database that needs to be unique and i am using datasets / tableadapters to interact with the database. when a user adds a new part number to the database i need to make sure its not already there
i have tried to use
catch ce as constraintexception
debug.print ce.tostring
end try

but the program still crashes with

System.Data.ConstraintException was unhandled ( see full error below)


no matter where i put the try statement it says its unhandeled

this error triggers when when i leave the combo box (when its validated) i have even tried placing it here


Private Sub PartNumberComboBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles PartNumberComboBox.Validating

Try

Catch CE As ConstraintException

Debug.Print(CE.Message)

Catch EX As Exception

Debug.Print(EX.Message)

End Try



End Sub

if someone could point me in the right direction id greatley appriciate it

System.Data.ConstraintException was unhandled
Message="Column 'PartNumber' is constrained to be unique. Value '36LDVRRP' is already present."
Source="System.Data"
StackTrace:
at System.Data.UniqueConstraint.CheckConstraint(DataRow row, DataRowAction action)
at System.Data.DataTable.RaiseRowChanging(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction, Boolean fireEvent)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Int32 position, Boolean fireEvent, Exception& deferredException)
at System.Data.DataTable.SetNewRecord(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean fireEvent)
at System.Data.DataRow.EndEdit()
at System.Data.DataRowView.EndEdit()
at System.Windows.Forms.CurrencyManager.EndCurrentEdit()
at System.Windows.Forms.CurrencyManager.ChangeRecordState(Int32 newPosition, Boolean validating, Boolean endCurrentEdit, Boolean firePositionChange, Boolean pullData)
at System.Windows.Forms.CurrencyManager.set_Position(Int32 value)
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.GroupBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Inventory_System.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:


View 9 Replies View Related

SQL Server 2014 :: Sanitizing Inputs When Creating String By Concatenation

Mar 19, 2014

I have a need to create a table in a sql server database from C# code. The kicker is that the user must be able to specify the table and field names via the UI. I can do a bit of sanity checking but as long as they enter something reasonable I need to accept it. Normaly I always ADO parameters to sanitise any user parameters but they can't be applied to table and field names, only values. As far as I'm aware that leaves me needing to concatenate strings and that's something I usually avoid like the plague due to risk of SQL injection.

My actual question : Assuming string concatenation is my only way forward, how can I sanitise the values that would go into the table name and fieldname bits of a CREATE TABLE statement to ensure that injection can't occur? I've been pondering it and I think I just need to check for semi-colons. Without a semi-colon I don't think a user could inject an extra statement could they?

View 3 Replies View Related

Data Access :: JDBC Stored Procedure Optional Inputs

Oct 4, 2015

When using JDBC is it possible to ignore input parameters in a stored procedure if they have default values?

I can create a string and execute a PreparedStatement but I'd like to use a Callable Statement.

View 7 Replies View Related

Validating Imported Values

Jan 18, 2005

I am using the following SQl statement in a DTS vb file.
The data is coming from an Excel spreadsheet and being put into a SQl server table.

oCustomTask1.SourceSQLStatement = "select `Order No`,`Country`,`Desc`,`Amount` from `Sheet1$` WHERE `Order No` = 1 "


I want to validate the data being put into the table to ensure no duplicates records are entered UNLESS the record has changed in any way.
E.g. If record 1 had a column called "NumberOne" which changed to "Number1" change this information and move the original value to another table.

View 2 Replies View Related

Validating Data Through Sql Server

Dec 21, 2007

hi guys, have a good day.

i have a table with a column named "cardRange", that column can only have integer values from 0 to 5.

i want the validation in the value that will be inserted in that column to be made in my sql server rather than in my programmed software.

Is there a way to validate (through a storedprocedure, or a trigger, or a column propertie) the values i want to add to my table??

In other wordsI just want my table to make sure that only a integer from 0 to 5 (or any other simple validation) can be added to the table.

Any help? thank you very much.

View 2 Replies View Related

Validating @ , And Length Of An Email

Feb 23, 2006

Im trying to perform an insert but with only valid emails that meet the following criteria:

Valid email : not Null, length > 6 with @ character

I know the is NOT NULL, but the other two im a bit confused on. :)

View 10 Replies View Related

Validating All Stored Procedures

Oct 4, 2006

... does anybody of you have a script for validating all stored procedures within a sql-server database (2000) ...

thanks in advance

Greetings
Stefan

View 5 Replies View Related

Validating And Updating Colums

Jul 23, 2005

Hi all,I am a newbie to sql and I need your help.I want to update column (email) from one table to another validating theCustomerid column in both table. Update the email address in productiontable with the email address in temp table if the customerid is same in bothtables.What would be the query?Thanks,

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved