How to Declare Variable in SQL Server Stored Procedure
In this section in SQL Server see about How to declare variable in SQL Server Stored Procedure.In this Section Use NorthWind Database in our Sql Server.
Use declare keyword to declare the variable @ConName set particular datatype. use set as assign the value from Database selected queries. The Unique value as assign to the variable in the Stored Procedure. Finally Display the output use Print Keyword.
Sven Ottlieb
91
Use declare keyword to declare the variable @ConName set particular datatype. use set as assign the value from Database selected queries. The Unique value as assign to the variable in the Stored Procedure. Finally Display the output use Print Keyword.
Example
create procedure proc_sample1
as
begin
declare @ConName as varchar(max)
declare @cuscount as int
set @ConName=(select ContactName from Customers where CustomerID='DRACD')
set @cuscount=(select COUNT(*) from Customers)
print @ConName
print @cuscount
end
Output
91
Comments
Post a Comment
Thank You for your Comment