Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when creating database name using full of number in SQL Server 2008 R2

Create a database name using string, database will create successfully.

Example :

if db_id('Database1') is null create database Database1

Command(s) completed successfully.

But create database name using full of number, it having a problem

Example :

if db_id('1234567890') is null create database 1234567890

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '1234567890'.

Is anything wrong in my query?

like image 320
Vikram Bose Avatar asked Jan 14 '23 08:01

Vikram Bose


1 Answers

Try this one -

IF DB_ID('1234567890') IS NULL 
    CREATE DATABASE [1234567890]
like image 128
Devart Avatar answered Jan 19 '23 11:01

Devart