Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I'd like to know, to pass a db-Name to a stored procedure

EDIT
my code is like
USE [master];
GO
 
SET ANSI_NULLS ON 
GO 
SET QUOTED_IDENTIFIER ON 
GO 
 
CREATE PROCEDURE [dbo].[usp_BACKUP_DB]
(
@DB_Name	VARCHAR(50),	-- Provide the DB's Name, whitch is to Back Up
@Drive	 VARCHAR(1)	-- Provide a Drive-Letter, e.g. C
)
 
AS
 
SET NOCOUNT ON 
 
IF (NOT @DB_Name IS NULL) AND (NOT @Drive IS NULL)
 
SET @_DB_Name = RTRIM(LTRIM(@DB_Name))
SET @_Drive = UPPER(RTRIM(LTRIM(@Drive)))
 
ALTER DATABASE @DB_Name
SET RECOVERY FULL;	 -- SET Recovery-Mode to FULL
GO

But @DB_Name and @Drive are not accepted by SQL Server:
Msg 102, Level 15, State 1, Procedure usp_BACKUP_DB, Line 20
Incorrect syntax near '@DB_Name'...
Posted
Updated 19-Jul-11 20:55pm
v2

As a string.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900