running many CREATE VIEW and GRANT SELECT statements in one execution
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
Is there a way to run multiple CREATE VIEW commands and/or multiple GRANT SELECT commands by hitting F5 in SQL Server Management Studio? If so, how can I do this?
sql-server ssms view
add a comment |Â
up vote
1
down vote
favorite
Is there a way to run multiple CREATE VIEW commands and/or multiple GRANT SELECT commands by hitting F5 in SQL Server Management Studio? If so, how can I do this?
sql-server ssms view
1
You just need the batch terminator, which in SSMS isGO
unless you altered this default
– scsimon
Sep 4 at 20:05
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Is there a way to run multiple CREATE VIEW commands and/or multiple GRANT SELECT commands by hitting F5 in SQL Server Management Studio? If so, how can I do this?
sql-server ssms view
Is there a way to run multiple CREATE VIEW commands and/or multiple GRANT SELECT commands by hitting F5 in SQL Server Management Studio? If so, how can I do this?
sql-server ssms view
edited Sep 8 at 12:37
mathewb
6821420
6821420
asked Sep 4 at 19:48


MacGyver
94592548
94592548
1
You just need the batch terminator, which in SSMS isGO
unless you altered this default
– scsimon
Sep 4 at 20:05
add a comment |Â
1
You just need the batch terminator, which in SSMS isGO
unless you altered this default
– scsimon
Sep 4 at 20:05
1
1
You just need the batch terminator, which in SSMS is
GO
unless you altered this default– scsimon
Sep 4 at 20:05
You just need the batch terminator, which in SSMS is
GO
unless you altered this default– scsimon
Sep 4 at 20:05
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
Multiple CREATE VIEW statements can be executed together if you separate them with keyword 'GO'
CREATE VIEW vw_test1 AS SELECT name FROM dbo.test1;
GO
CREATE VIEW vw)test2 AS SELECT name FROM dbo.test2;
GO
GRANT SELECT ON vw_test....
add a comment |Â
up vote
3
down vote
You can use dynamic SQL. Encapsulate your CREATE VIEW and/or GRANT SELECT statement in text.
ex:
DECLARE @Query NVARCHAR(50)
SET @Query = 'CREATE VIEW ... '
exec sp_executesql @Query
You can do that for all the queries you need to run and then just press F5
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Multiple CREATE VIEW statements can be executed together if you separate them with keyword 'GO'
CREATE VIEW vw_test1 AS SELECT name FROM dbo.test1;
GO
CREATE VIEW vw)test2 AS SELECT name FROM dbo.test2;
GO
GRANT SELECT ON vw_test....
add a comment |Â
up vote
4
down vote
accepted
Multiple CREATE VIEW statements can be executed together if you separate them with keyword 'GO'
CREATE VIEW vw_test1 AS SELECT name FROM dbo.test1;
GO
CREATE VIEW vw)test2 AS SELECT name FROM dbo.test2;
GO
GRANT SELECT ON vw_test....
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Multiple CREATE VIEW statements can be executed together if you separate them with keyword 'GO'
CREATE VIEW vw_test1 AS SELECT name FROM dbo.test1;
GO
CREATE VIEW vw)test2 AS SELECT name FROM dbo.test2;
GO
GRANT SELECT ON vw_test....
Multiple CREATE VIEW statements can be executed together if you separate them with keyword 'GO'
CREATE VIEW vw_test1 AS SELECT name FROM dbo.test1;
GO
CREATE VIEW vw)test2 AS SELECT name FROM dbo.test2;
GO
GRANT SELECT ON vw_test....
answered Sep 4 at 20:04
Unkush
1103
1103
add a comment |Â
add a comment |Â
up vote
3
down vote
You can use dynamic SQL. Encapsulate your CREATE VIEW and/or GRANT SELECT statement in text.
ex:
DECLARE @Query NVARCHAR(50)
SET @Query = 'CREATE VIEW ... '
exec sp_executesql @Query
You can do that for all the queries you need to run and then just press F5
add a comment |Â
up vote
3
down vote
You can use dynamic SQL. Encapsulate your CREATE VIEW and/or GRANT SELECT statement in text.
ex:
DECLARE @Query NVARCHAR(50)
SET @Query = 'CREATE VIEW ... '
exec sp_executesql @Query
You can do that for all the queries you need to run and then just press F5
add a comment |Â
up vote
3
down vote
up vote
3
down vote
You can use dynamic SQL. Encapsulate your CREATE VIEW and/or GRANT SELECT statement in text.
ex:
DECLARE @Query NVARCHAR(50)
SET @Query = 'CREATE VIEW ... '
exec sp_executesql @Query
You can do that for all the queries you need to run and then just press F5
You can use dynamic SQL. Encapsulate your CREATE VIEW and/or GRANT SELECT statement in text.
ex:
DECLARE @Query NVARCHAR(50)
SET @Query = 'CREATE VIEW ... '
exec sp_executesql @Query
You can do that for all the queries you need to run and then just press F5
answered Sep 4 at 19:54


Danielle Paquette-Harvey
5381414
5381414
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f216718%2frunning-many-create-view-and-grant-select-statements-in-one-execution%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You just need the batch terminator, which in SSMS is
GO
unless you altered this default– scsimon
Sep 4 at 20:05