Showing posts with label Parameters. Show all posts
Showing posts with label Parameters. Show all posts

Thursday, January 25, 2018

Executing a stored procedure in Microsoft SQL Operations Studio(SQLOPS)

Executing a stored procedure is as easy as running query in SQLOPS.

For example, I restored the Northwind database from a backup file from CodePlex site to the default instance of SQL Server 2017 Developer's Edition.

I connected to the SQL Server 2017 in Microsoft SQLOPS as shown. Here you can see all the objects in the server.



SP_SQLOPS_0

Right click the stored procedure (herein, dbo.CustOrderHist) to display a pick list as shown.



SP_SQLOPS_1

Click Script as Execute.
A query is created as shown:


SP_SQLOPS_2

In the TODO section add-in the value of CustomerID.
Look up the data type of CustomerID as shown here:


SP_SQLOPS_3


You need to modify this query somewhat to see the results (this is Preview software). Add statements to the SQLOPS created script to read as shown here:
---------------------
USE Northwnd
GO
DECLARE @RC int
DECLARE @CustomerID
nchar(5)
-- TODO: Set parameter values here.
Set @CustomerID='ALFKI'
EXECUTE @RC = [dbo].[CustOrderHist]
   @CustomerID
GO
-----------------
Now click Run and you can see the response as shown:

That's all.

Thursday, April 14, 2016

Creating a Scalar-valued function in SQL Server 2014

First of all what is a Scalar-valued function?

A scalar function in SQL Server is similar to the generally accepted meaning function, a function is defined by the variables (parameters) with some operation on them and the resulting value is the return value of the function.

  • If x and y are the variables(parameters) than the
    function(x,y)=x+y defines a scalar function that returns a value which is the sum of x and y.
  • The scalar function is not limited to just two parameters and can have more.

Where do you find the Scalar-valued function in the Object Explorer?

You will find the Scalar-valued function node in all the databases in the Programmability node as shown here for AdventureWorks2012 database.

Sway5_01

How do you create a Scalar-Valued Function in SQL Server Management Studio?

Watch this Swaytorial.
https://docs.com/jayaram-krishnaswamy/9721/creating-a-scalar-valued-function-in-sql-server


When Identity Security Becomes a Wall — Not a Shield

After a breach that forced a reset of my digital identity, I hit a roadblock I never anticipated: multi-factor authentication (2FA) locked m...