Forum Discussion
raluca_suditu
13 years agoContributor
Hello,
I have a problem. I want to pass the name of a database into a variable but I don't know how. I do like this in my code:
I have a problem. I want to pass the name of a database into a variable but I don't know how. I do like this in my code:
var
commands = new Array();
var variable="@DBNAME";
commands[commands.length] = "DECLARE " + variable + " NVARCHAR(max) select " + variable + " = name from sys.databases where name like xxx_%' print @DBNAME";
// Create a new object
var Cmd =
ADO["CreateADOCommand"]();
// Specify the connection string
Cmd["ConnectionString"]="Driver={SQL Server};Server=xxx;Uid=xxx;Pwd=xxx";
// Specify the command type
Cmd["CommandType"]=cmdText;
for(var i = 0; i < commands.length; i++)
{
// Specify the command text (an SQL expression)
Cmd.CommandText = commands;
// Execute the command
Cmd.Execute();
}
Log["Message"](variable);
return variable;
But the result is '@DBNAME not ''xxx_' as I expect.
Regards,
Raluca
Related Content
- 2 years ago
- 9 years ago
Recent Discussions
- 2 days ago
- 2 days ago
- 6 days ago