I have a base in Microsoft SQL Server. I got the file with the stored procedure. How can I add it to my database? I tried to execute the contents of the file, but I get an error. Below are examples of errors and part of the text of the procedure.

Invalid object name 'dbo.unefficient_block'.

USE [rum] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[unefficient_block] AS BEGIN DECLARE @calls int DECLARE @msisdn nvarchar(20) DECLARE @status int DECLARE @warn_sms int declare @lang int declare cur1 CURSOR FOR select nds, count(*) as calls from rum.dbo.unefficient_calls where nds not in (select phone from rum.dbo.huly h) -- and nds not in (select msisdn COLLATE SQL_Latin1_General_CP1_CI_AS from rum.dbo.unefficient_status s where status=1) group by nds 

    1 answer 1

    Replace

     ALTER PROCEDURE [dbo].[unefficient_block] 

    on

     CREATE PROCEDURE [dbo].[unefficient_block] 

    ALTER modifies an existing object. Because In your database there was no procedure [dbo].[unefficient_block] , you need not to change it, but create it using CREATE .

    • Thank! The procedure has been created!) But for some reason it still emphasizes [dbo]. [unefficient_block] in red and writes invalid object name? - Eugene
    • @ Eugene "underlines" - is this in SqlServer Management Studio? There in the settings there is an update cache: Edit-> Intellisence-> Refresh Local Cache (Ctrl + Shift + R) - i-one
    • Yes in it. Sorry for stupid questions) - Eugene
    • Thank you so much!) - Eugene