TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
D V Krishna Reddy
NA
45
6.1k
How to declare Dynamic Variable names
Aug 21 2019 1:41 AM
Hi,
I need to how to declare dynamic variable names from table in a stored procedure i am using like below .but it wont work can anyone help me out .
WHILE @i < 6 --- (select Count(*) from List_Of_SMSC_Gateways where IsDeleted=0 )
BEGIN
select @gwayName= Gateway_Name from (SELECT ROW_NUMBER() OVER (ORDER BY Gateway_Name Asc) AS Rno, Gateway_Name
from List_Of_SMSC_Gateways where IsDeleted=0 ) as x where x.Rno=@i
set @sql=@sql+' Declare @'+@gwayName+'_reseller_Count Numeric = 0 , @'+@gwayName+'_smcountry_count Numeric = 0;'
set @sql=@sql+' Declare @Smsc_'+@gwayName+'_Total_count Numeric=0;'
set @sql=@sql+' Declare @Resller_'+@gwayName+'_Total_count Numeric=0;'
set @sql=@sql+' Declare @Total_'+@gwayName+'_cnt Numeric=0;'
set @i=@i+1
END;
execute(@sql)
and need to use this variable across stored procedure
thanks in advance
Reply
Answers (
2
)
How to print a relational model from SSMS
Clause ORDER BY doesn’t work in VIEWS