I need to do a simple truncate on a table named myTable
. So I wrote this and it works:
statelessSession
.CreateSQLQuery("TRUNCATE TABLE myTable")
.ExecuteUpdate();
Since I would store table name in an App.config I would "parameterize" the query. I would avoid String.Format
and so I tried something like
statelessSession
.CreateSQLQuery("TRUNCATE TABLE :tabName")
.SetParameter("tabName", SysCfg.ConfigurationManager.AppSettings["tabName"])
.ExecuteUpdate();
but when I run this code I get:
Additional information: could not execute native bulk manipulation query:
TRUNCATE TABLE :seedTableName[SQL: TRUNCATE TABLE @p0]
I also tried with curly braces around parameter name but this doesn't work as well.
Where Am I wrong?