August 6, 2013 at 2:49 am
Very simple question to somebodyt who knows
declare @Databasename varchar(50)
select @Databasename = (select DB_NAME() )
select @Databasename
EXECUTE master.dbo.xp_create_subdir N'W:\MSSQL10_50.LIVE802MSSQL\MSSQL\Backups\ ' + @Databasename
I have tried a ridiculous amount of different variations of the quotations around the variable at the end but can not seem to get it right.
Any help would be appreciated before i self distruct
August 6, 2013 at 3:19 am
Steveyam90 (8/6/2013)
Very simple question
What is your question?
John
August 6, 2013 at 3:27 am
Does this work?
DECLARE @Databasename NVARCHAR(50);
DECLARE @Subdir NVARCHAR(150);
SELECT @Databasename = (SELECT DB_NAME());
--SELECT @Databasename;
SELECT @Subdir = N'C:\Test\' + @Databasename;
--SELECT @Subdir;
EXECUTE master.dbo.xp_create_subdir @Subdir;
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
August 6, 2013 at 3:34 am
Koen Verbeeck (8/6/2013)
Does this work?
DECLARE @Databasename NVARCHAR(50);
DECLARE @Subdir NVARCHAR(150);
SELECT @Databasename = (SELECT DB_NAME());
--SELECT @Databasename;
SELECT @Subdir = N'C:\Test\' + @Databasename;
--SELECT @Subdir;
EXECUTE master.dbo.xp_create_subdir @Subdir;
It does indeed! thank you! Sanity saved!
August 6, 2013 at 3:34 am
An expression ('abc' + @z) is not permitted as a parameter to a procedure. Parameter has to be variable (or another parameter) or a constant
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy