We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [exec]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
8
votes
4answers
13k views

Get @@SERVERNAME from linked server

This seems like a basic question but I can't find any answers out there - I need to be able to get the server name/instance etc. from a linked server. I've tried a couple of things: select <linked ...
0
votes
3answers
137 views

Must declare the scalar variable question

That is my first post here, need helps: in a stored procedure I had some following code CREATE PROCEDURE [dbo].[SP_getAvg] ( @projectId INT ,@carrierId INT ,@fetchType VARCHAR(20) ) ...
2
votes
1answer
460 views

SQL Server: what additional permissions for EXECUTE for implicit result codes?

Tested on: 2014+SP2+CU7, 2016+SP1+CU5, 2016+SP2 Short description: User with EXECUTE permission still gets Cannot find the object 'sp_fakeProcedureName', because it does not exist or you do not ...
0
votes
1answer
591 views

How can I stop script execution if insert value is null and set value if not null?

I have tried to use Case and SET NOEXEC ON but get the following errors: Syntax Error: unexpected 'SET' (set) Syntax Error: missing 'closing parenthesis' INSERT INTO tag (table, repr, tag, ...
5
votes
1answer
1k views

Insert Into table Exec SP with bad performance

I am working on a datawarehouse. One of our staging tables that is refreshed every night has about 10 million rows. We are using a custom built ETL tool that I can't make too many changes to. The tool ...
7
votes
3answers
11k views

EXEC vs SP_EXECUTESQL Performance

Recently we used a sql code reviewing tool against our database. It is suggesting to use SP_EXECUTESQL instead of EXEC. I know SP_EXECUTESQL helps us to avoid sql injection. Is there any difference ...
0
votes
1answer
61 views

How can i make SQL exec statements run in order [closed]

SQL server 2012, I have multiple execs calling the same package with different parameters. Normally i'll highlight one at a time and run them individually but I'd like to be able to hit go and run ...
1
vote
1answer
1k views

Insert openquery results into an existing table

I have a stored procedure that queries a linked DB2 server in this fashion: SET @sql='SELECT * FROM openquery(DB2,''SELECT column1, column2 FROM table'')' exec sp_executesql @sql I am trying to ...
1
vote
3answers
1k views

How to extract dynamically data from another database in function with DBName as parameter?

I have one main database (MAIN) and several client DBs (CLIENTDB). I need to start query in MAIN and to get data from CLIENTDB. The client DB can be found also on linked server. My problem is that I ...