This issue is so frustrating. I am hoping someone knows the answer to this specific question.
Why would sql server insist that a database does not exist even though it obviously does exist?
I get the error message: Database 'tf_1' does not exist.
Why would it say it does not exist when it is clearly viewable in SMSS. It attached without problem. I can view the tables in the database. I know it's there; SMSS knows it's there; the VB app I wrote knows it's there. But, when I try to run a query to copy a table from one database to another, sql server says it doesn't exist! What gives?
Yes, I asked this question before but nobody answered. The problem is back!
This is the sql statement in vb:
sql = "SELECT [DateTime], [Open], [High], [Low], [Close], [Volume] INTO "
sql = sql & DestDbName & ".dbo." & TableName
sql = sql & " FROM " & TableName & ";"
The connection string:
strDbConn = "Provider=SQLNCLI;Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"AttachDBFileName=" & DbPath
is used to open a connection to the source database.
You can't specify an object name like that as a variable. Use a literal variable there, or put the object names in a temp table and cursor through them that way. There are solutions available in scripts across the web - check here:
http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true
|||
I am not sure if you can do this opertaion (inserting into other database) when you connect to DB FILE instaed of the server.
I don think you are trying to insert the data into the same database, but if you are you do not have to specify the database name.
No comments:
Post a Comment