Re: support for bind variables?



"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
--


.



Relevant Pages

  • Re: Unifying Temp table behavior across oracle, mssql
    ... on oracle the TABLE is visible to other sessions after its ... products support things in the same manner. ... Poor app design to use auto commit - this is a possibility. ... Because we have to support SQL Server, we have to be careful about ...
    (comp.databases.oracle.server)
  • Re: Unifying Temp table behavior across oracle, mssql
    ... on oracle the TABLE is visible to other sessions after its ... products support things in the same manner. ... Poor app design to use auto commit - this is a possibility. ... Because we have to support SQL Server, we have to be careful about ...
    (comp.databases.oracle.server)
  • Re: Import problems on Windows Server
    ... your OWN research the Mickeysoft ODBC drivers do NOT support ANY ... Oracle feature beyond 7.3? ... There are plenty of non MS ODBC drivers that will connect with the various editions of non-MS databases, some of the drivers are actually better. ... Free speech - I'm here to stay dude - get used to it; when you see a post relating to SQL Server or Windows I'll be there with an answer to any myth you might want to TRY and spread. ...
    (comp.databases.oracle.server)
  • Re: Retrieve error text from extended stored proc
    ... was only on first execution, the following executions, error number was 0. ... However, use OSQL with the -m-1 switch, and you will see that the RAISERROR ... Tibor Karaszi, SQL Server MVP ... > When I call the stored proc from Query Analyzer and force an error, ...
    (microsoft.public.sqlserver.programming)
  • Re: best way to retrieve thousands of records.
    ... I understand you should have a chunky not chatty interface, ... i.e code up another stored proc that accepts ... > retrieve records from sql server. ...
    (microsoft.public.dotnet.languages.vb)