There is already an object named '#columntable' in the database
Temp tables are not dropped automatically at the end of a query, only when the current connection to the DB is dropped or you explicitly delete them with DROP TABLE #columntable
Either test for the existence of the table at the start of the query or alwayas delete it at the end (preferably both)
EDIT: As Matrin said in his comment, this is actually a parse error. You get the same error if you only parse the SQL as when you execute it.
To test that out I split up your query and tried:
if exists (select 1 from emp where id = 6)
create table #columntable (newcolumns varchar(100))
GO
if not exists (select 1 from emp where id = 6)
create table #columntable (oldcolumns varchar(100))
GO
The parser is happy with that. Interestingly if you change to using non-temp tables the original query parses fine (I realise the problems that would create, I was just interested to find out why the query would not parse).
Stored Procedure: There is already an object named '#columntable' in the database
As per SQL Server specification, it is not allowed. Please refer to the documentation.
If more than one temporary table is created inside a single stored
procedure or batch, they must have different names.
You are creating two temporary tables, with the same name #dbreviews
. This is not allowed.
There is already an object named in the database
it seems there is a problem in migration process, run add-migration command in "Package Manager Console":
Add-Migration Initial -IgnoreChanges
do some changes, and then update database from "Initial" file:
Update-Database -verbose
Edit:
-IgnoreChanges is in EF6 but not in EF Core, here's a workaround:
https://stackoverflow.com/a/43687656/495455
Odd error using IF/ELSE IF statements
Since only the top number of records are difference. You can try this
declare @num int
SET @num = CASE @indexName
WHEN 'A' THEN 400
WHEN 'B' THEN 75
WHEN 'C' THEN 300
ELSE 100
END
select top (@num) * into #temp from #pretemp order by EMRev desc
Play slick 3 binding/conversion object to column table
You need to add mapping from relational model to object model and vice versa.
sealed trait Occupation
object Occupation {
implicit val occupationType = MappedColumnType.base[Occupation, String](
{ occupation => if(occupation==Teacher) "Teacher" else if (occupation == Student) "Student" else "Others"},
{ occupation => if(occupation == "Teacher") Teacher else if (occupation == "Student") Student else Others }
)
case object Teacher extends Occupation
case object Student extends Occupation
case object Others extends Occupation
}
Here is more details: http://slick.typesafe.com/doc/3.0.0/userdefined.html
How can I get column names from a table in Oracle?
You can query the USER_TAB_COLUMNS table for table column metadata.
SELECT table_name, column_name, data_type, data_length
FROM USER_TAB_COLUMNS
WHERE table_name = 'MYTABLE'
Related Topics
Convert Timestamp to Date in Oracle SQL
Autoincrement Fields on Databases Without Autoincrement Field
Get Size of Large Object in Postgresql Query
Return Rows from Insert with on Conflict Without Needing to Update
Difference Between Varchar(500) VS Varchar(Max) in SQL Server
When Are Database Triggers Bad
"Ora-01438: Value Larger Than Specified Precision Allowed for This Column" When Inserting 3
Run Stored Procedure and Return Values from Vba
How to Specify 'Default' as a SQL Parameter Value in Ado.Net
SQL Server 2008 Cross Tab Query
SQL Server:Export Query as a .Txt File
Check Constraint on Date of Birth
SQL Server Regular Expressions
Oracle Autoincrement with Sequence and Trigger Is Not Working Correctly
How to Understand How Value Converted to Date Format Implicitly
How to List Active Connections on Postgresql