I've been looking for a while but still can not find the answer. I am trying to use a very simple stored procedure sp_executesql to create a database or a table.
exec sp_executesql
N'create database @d',
N'@d nvarchar(1)',
@d = 'a';
or this
exec sp_executesql
N'create table @d',
N'@d nvarchar(9)',
@d=N'MyTable'
keep getting this message:
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '@d'.
I dont understand why?