每次创建存储过程时,它都默认为“master”数据库。如何制作特定于数据库“上传”的SP?
CREATE PROCEDURE testInsert2
AS
INSERT INTO [uploads].dbo.[aspnet_uploads]
(userID, fileName, userName)
VALUES
('Test1', 'Test2', 'Test3')
答案 0 :(得分:4)
您需要处于该数据库的上下文中。
USE uploads;
GO
CREATE PROCEDURE dbo.testInsert2
AS
BEGIN
SET NOCOUNT ON;
INSERT dbo.[aspnet_uploads](userID, fileName, userName)
VALUES('Test1', 'Test2', 'Test3');
END
GO
答案 1 :(得分:0)
当您重新连接服务器时,它会发生。你可以这样试试
USE [database_name]
GO
Create Procedure [procedure_name]
AS