Solved

When passing parameters to MS SQL Server Stored Procs, do we send values or pointers?

Posted on 2006-06-27
4
207 Views
Last Modified: 2012-05-05
A theoretical question, having spotted an inconsistency while reviewing someone's code:

If I pass a Smallint variable to a stored procedure as a parameter, and the parameter is defined in the stored procedure as an Interger, can this cause problems?

I suspect that an implicit conversion is done for me, but it occurred to me that if SQL handles this by passing a pointer to the variable (as when passing variables using "ByRef" in Visual Basic), the stored procedure could decide to pick up the four bytes following the pointer and end up with the wrong value in the parameter.

Thanks for taking the time to read this.

0
Comment
Question by:johnhyde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16993186
> can this cause problems?
yes it can, if the parameter is of type OUTPUT and a value larger than smallint is returned.

regarding the value passed into the proc, there is no issue
0
 

Author Comment

by:johnhyde
ID: 16993634
Thanks for this, angelIII.

Certaily no argument regarding OUTPUT parameters.  So is it the case that values, rather than pointers are passed, and SQL Server implicitly converts where necessary?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 16993739
yes
0
 

Author Comment

by:johnhyde
ID: 16994030
That's what I wanted to know - many thanks for the speedy response.
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Copy data to New Year 9 33
I need help using SQL case statements in where clauses 3 25
removing unwanted rows from an sql server ranked table 13 37
SQL profiler 3 20
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question