Re: support for bind variables?
- From: "David Portas" <REMOVE_BEFORE_REPLYING_dportas@xxxxxxx>
- Date: Sat, 4 Mar 2006 15:19:36 -0000
"G_Allen" <GAllen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:05434D45-B17D-4D97-A1EB-C90AB4CAEE47@xxxxxxxxxxxxxxxx
I recently did a little development on an Oracle database and utilized bind
variables in a script like this:
SELECT first_name, last_name, zip FROM customers WHERE id = :cust_no
and simply defined ":cust_no" as a parameter through my application code.
I
found this statement in an Oracle discussion:
"Support for bind variables isn't just limited to Oracle - it's common to
other RDBMS platforms such as Microsoft SQL Server..."
but can't find anything to corroborate it in SQL Server support. How do I
pass parameters to a SQL Script without having to build a Stored Proc?
Well firstly why wouldn't you want to create a stored proc? In SQL Server it
is best practice to perform ALL data access through stored procs unless you
have a special reason not to. Procs have so many advantages that are just
too numerous to go into in full: better security, performance, scalability,
ease of maintenance, version control, etc, etc.
The following are examples of passing parameters in .NET both with and
without procs:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingstoredprocedureswithcommand.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingparameterswithdataadapters.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconinputoutputparametersreturnvalues.asp
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
.
- Next by Date: [OT] User-Defined string Functions MS SQL Server 2005 Transact-SQL
- Next by thread: [OT] User-Defined string Functions MS SQL Server 2005 Transact-SQL
- Index(es):
Relevant Pages
|
|