0

What I am missing to get data from temporary table. This is showing error like Invalid object name #emp. Please help me I am using Asp.net.

 Dim sqlcmd = New SqlCommand("select * into #emp from employees", conn)
 sqlcmd.ExecuteNonQuery()

 sqlcmd = New SqlCommand("select * from  #emp", conn)
 Dim dr As SqlDataReader = sqlcmd.ExecuteReader

See Above query is working fine and data is going into temporary table. but it is not selecting again through second one query.

Thanks

0

1 Answer 1

2

Try to use Global Temporary table instead of Local Temporary tabel like.. ##emp

or

You can just use a stored procedure which has all the SQL statement you want to execute and return your desired recordset.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.