SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


declaring global variables


declaring global variables

Author
Message
BeginnerBug
BeginnerBug
Right there with Babe
Right there with Babe (725 reputation)Right there with Babe (725 reputation)Right there with Babe (725 reputation)Right there with Babe (725 reputation)Right there with Babe (725 reputation)Right there with Babe (725 reputation)Right there with Babe (725 reputation)Right there with Babe (725 reputation)

Group: General Forum Members
Points: 725 Visits: 350
Hi,

In Oracle, we can set the public variable/constant/types/curosors in the Package specification, Could you please tell me that how to achieve the same functionality in the SQL server.

Thanks in Advance
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13479 Visits: 4639
mail4sha (10/9/2010)
In Oracle, we can set the public variable/constant/types/curosors in the Package specification, Could you please tell me that how to achieve the same functionality in the SQL server.

There is not such a thing as a package in SQL Server but you use DECLARE statement to declare variables, etc. Check here... http://msdn.microsoft.com/en-us/library/aa258839(SQL.80).aspx

Hope this helps.

_____________________________________
Pablo (Paul) Berzukov

Author of Understanding Database Administration available at Amazon and other bookstores.

Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Vedran Kesegic
Vedran Kesegic
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1842 Visits: 1266
No packages in SQL Server, unfortunately. Packages are one of Oracle advantages over SQL Server (do not start a war, please Smile ).
But, you have several other options to make data shareable between procedures (beside obvoius: parameters):

#temporary tables
##global temporary tables
context_info - 128 bytes of connection-scoped data. varbinary(128), initially NULL.

declare @vb varbinary(128)
set @vb = context_info() -- read value
set context_info @vb -- set value



You can use e.g. one byte of the binary string for one variable, next four bytes for other variable etc.
Also, @table variables can be input parameters for procedure from sql2008 and up.

_____________________________________________________
Microsoft Certified Master: SQL Server 2008
XDetails Addin - for SQL Developers
blog.sqlxdetails.com - Transaction log myths

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search