May 5, 2008 at 11:25 pm
Hi,
I'm running SQL Server 2000 and PHP.
I believe the problem I have is SQL Server based and not the PHP, but I have no idea where to look.
If I use the Northwind database, I can query the database from PHP in the normal manner (without the need for a database name in the query):
SELECT * FROM person;
But if I use my own database, I have to amend the query to
SELECT * FROM db_name.person
I'm sure this is something in SQL Server that I have overlooked.
Any ideas.
Tks.
May 6, 2008 at 12:03 am
[font="Verdana"]check the connection string, which database you have mentioned in it. Correct it with the desired DB Name.
Mahesh[/font]
MH-09-AM-8694
May 6, 2008 at 12:10 am
Hi Jonp
As Mahesh state the problem is more likely with the connection string. Can you write the connection string, which you have used, here?
May 6, 2008 at 12:26 am
Thanks for the responses, however I have no discovered that this is certainly something to do with SQL Server installation and the way I have created the databases.
I created the database that I cannot connect to properly with a backup of and old database. I did not create the database first and then restore the backup, but did it all at the same time.
I have now tried it again, this time creating an empty database first, then restoring the backup.
I can now access the data correctly, without having to use the database name in the queries, but I notice that all the tables are now owned by dbo .... will that cause a problem in future?
Thanks again for your help.
Jon.
May 6, 2008 at 6:01 am
No it will not create any problem.
May 7, 2008 at 1:34 pm
Hello,
Also use the USE command.
Like
USE SALES
or
USE MASTER
The USE command points the query to to a specific data set.
.dbo = data base owner and is a default for owner of most tables.
So a full dot notation reference can be used like
select *
from SALES.dbo.SalesData
Regards,
Terry
May 9, 2008 at 3:31 am
jonp (5/5/2008)
Hi,I'm running SQL Server 2000 and PHP.
I believe the problem I have is SQL Server based and not the PHP, but I have no idea where to look.
If I use the Northwind database, I can query the database from PHP in the normal manner (without the need for a database name in the query):
SELECT * FROM person;
But if I use my own database, I have to amend the query to
SELECT * FROM db_name.person
I'm sure this is something in SQL Server that I have overlooked.
Any ideas.
Tks.
see ,
SELECT * FROM db_name.person.tablename
is right way of creating query, because if some other user create new table in the same database then you must use this method.in this way you need not change your query in future
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply