sql - Create a DATABASE using as a Name from a Variable -


I want to create a database using a variable using Valuable. Here's my script but it does not work. any idea?

  - Set Data Base name DECLARE @ DataBaseName char (64); SET @ database name = 'DBCSSWiteTest'; - Create database of data base @ Database name;  

You think I need dynamic SQL for this (with proper caution if name is given by user)

  - Set Data Base name DECLARE @ DataBaseName sysname; SET @ database name = 'DBCSSWiteTest'; IF (@ DataAbaseName '% [^ 0- 9A-Z]%') Receiver ('name,% s', 16,1, like 'invalid characters in databasebase') ELSE BEGIN SET @ DataBaseName = QUOTENAME (@DatabaseBaseName) EXEC ('Create Database' + @ Database Name) END  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -