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
Sohail Shahzad
1.5k
262
849
Call sql view inside store procedure
Jun 14 2019 8:57 AM
Currently working on BI tool in .NET MVC. i have created procedure that accept sql statement as string to clone temp table from another table using select query. Now i want to create view of temp table that is recently created by using string.How to do i perform this task.
My code is
USE [AirViewX2_DEV]
GO
/****** Object: StoredProcedure [dbo].[Tmp_CloneOfDataset] ******/
SET
ANSI_NULLS
ON
GO
SET
QUOTED_IDENTIFIER
ON
GO
ALTER
PROCEDURE
[dbo].[Tmp_CloneOfDataset]
@Filter NVARCHAR(500),
@Value NVARCHAR(50)=
NULL
AS
BEGIN
SET
NOCOUNT
ON
--IF(@Filter='CLONE_OF_DATASET')
--BEGIN
DECLARE
@GetTemName
varchar
(200)= RTRIM(LTRIM(
SUBSTRING
(@Filter,CHARINDEX(
'into'
,@Filter)+4,CHARINDEX(
'from'
,@Filter)-CHARINDEX(
'into'
,@Filter)-4)))
IF EXISTS (
SELECT
*
FROM
INFORMATION_SCHEMA.TABLES
WHERE
TABLE_NAME = @GetTemName)
BEGIN
DECLARE
@alreadyExist
int
=1;
return
@alreadyExist
--DECLARE @SQL NVARCHAR(MAX)
--SELECT @SQL = 'DROP TABLE dbo.' + QUOTENAME(@GetTemName) + '';
-- EXEC sp_executesql @SQL;
EXECUTE
(@Filter)
END
ELSE
BEGIN
EXECUTE
(@Filter)
declare
@sqlcode
varchar
(
max
)
Here i want to create sql view for @GetTemName
--select @sqlcode = 'create view @GetTemName as select * from MyTable'
--@sqlcode+=' '@GetTemName
--exec (@sql)
DECLARE
@status
varchar
(200) =
'Done'
SELECT
@status
END
--END
END
Reply
Answers (
5
)
How to delete particular string from using request url
Navigating and displaying data on a ribbon window