Showing posts with label queries. Show all posts
Showing posts with label queries. Show all posts

Wednesday, March 28, 2012

ODBC Driver for AS400

Hi,

I am presently using Client Access ODBC driver (32-bit) to connect to the AS400. I have set up a linked server that enables me to run queries against the AS400 using the driver. However I seek to have a driver that could give better performance. Right now I can extract 6 million rows from the AS400 table in like 2 hrs. Now is there an ODBC driver that can do better than that? Also I seek an evaluation edition of the driver if possible. Moreover I am the only developer and so a single user license is what I can have my supervisor budget.

Thanks,

VivekLook at www.hitsw.com. I've never used their drivers, but a friend of mine did and he praised their performance to the sky.

Regards,

hmscott

Hi,

I am presently using Client Access ODBC driver (32-bit) to connect to the AS400. I have set up a linked server that enables me to run queries against the AS400 using the driver. However I seek to have a driver that could give better performance. Right now I can extract 6 million rows from the AS400 table in like 2 hrs. Now is there an ODBC driver that can do better than that? Also I seek an evaluation edition of the driver if possible. Moreover I am the only developer and so a single user license is what I can have my supervisor budget.

Thanks,

Viveksql

Monday, March 26, 2012

ODBC database slows down over time

Howdy,

I currently have an ODBC connection to a SQL server that exists on the other side of the country from me. I'm running queries in Access and I've found that over time, queries run slower and slower. If I create a new database and bring in the same tables, it runs quickly (relatively speaking) again. Why is this happening? Is there something I can do besides creating new databases all the time?

Thank you in advance.Is the problem that over time the query has more and more records to move through? Is the DB normalized?

ODBC connections and SSIS

so im trying to connect to an odbc source and use ado.net to pass some sql queries and then write back into this odbc connection. i am aware that ssis does not have direct capabilities to do this, but i wanted to see if anyone knew of generic help docs/url's that show how to do this? i am new to ssis, and am just trying to get general information.

See Douglas post here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=70469&SiteID=1

The code is also in SQL Books Online.|||

to be honest with you, i did see that thread you mention above, probably the only thread with realistic information. I am looking for something specifically in C#.

I am also wondering if there is any way to not have the SQL Command line filled for the ODBC connection source and use ODBC and a combination of ADO.net? Anyone have success with this?

I did search books online for the particualar phrase mentioned in the above thread..not too helpful.

Just wondering if anyone has had success writing C# ado.net to read and write using ODBC as a source?

thanks!

|||

If that's what you are after then I would try a dev forum if I were you: http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=12&SiteID=1

-Jamie

sql

Monday, March 12, 2012

ODBC & Multi-threading

I'm working on a C# (2005) app that requires shooting a large number of queries via Odbc, wait until the last one is done and then compute an overall result.

Since the queries are not interdependent, I would like to get them to run concurrently on multiple threads.

I did manage to get several queries run on different threads but the response time for the same query varies dramatically when another query is running concurently (even on a different ODBC connection). All is as if something was queing those queries regardless of the threads and/or the connection objects being used.

Basically when I run a very simple query q1 (thread 1 connection1) on its own, the result is instantaneous, but if I first start a big query q2 (thread 2, connection 2) and then q1 while q2 is running q1 takes forever.

Is it possible at all (for example, does the Odbc driver support being used that way)

Any suggestion as to how to handle that problem would be appreciated.

MM

I do not see why it could not be done. Miltithreading is basically the same as multiple connections from different clients at same time and it is definitely allowed. First it is quite possible that your first thread blocks another one until it finishes execution. In this case second block is doing nothing and just waits. Another potential issue is your big query is so *heavy* for the server that sever just uses 100% of its resources for this query. But I am doubt that this is the case|||

Are you using (nolocks) on your tables?

Select * from Customers (nolock)

Where yada yada yada

If you are not, one query is locking the table until the connection closes.

This is how it works:

1. Query1 --> Select * from Customers

Customers Table is locked until connection closes|||

Yes, I have no doubt that from a server standpoint there is no problem.

The question was more whether multiple queries running simultaneously from the same client machine may be a problem.

For example what if the ODBC driver queues the queries.

I read somewhere that depending on the provider some drivers may or may not support multithreading but have no ide whether it's true or if it has anything to do with my problem.

Thanks anyway,

MM

|||

Adamus,

Good thought, it may be the cause of my problem.

I did try shooting the queries at different tables and it seemed to work fine.

a- Now, for the (nolock); I believe this is a SQL Server specific syntax, do you know if there's a generic way to issue a 'dirty read' through ODBC without being tied to the syntax of particular vendor/DB ?

Would starting a transaction from the ODBCConnection used for the command and set its isolationlevel to 'UncommitedRead' work ?

b- Assuming there's a way of doing a dirty read. Any suggestion as to how best handle the following ? :

- Do first select and get a list of values

- For each of the values issue a scalar command and get the result

- Once all the results are collected, do something with them and display the final result.

The trick of course is to create as many threads are scalar commands to be issued since it would improve perfs to run them in parallel. But it has to be done dynamically since we don't know how many we'll get. Then we need the ability to tie everything back together. Not exactly obvious to do, at least to me.

Thanks,

MM

|||

ODBC? Kind of unfamiliar ground for me unfortunately. (I'm more of a SQL guy)The first thing that comes to mind is .LockType

...but good luck :)

Adamus

|||

.Locktype ? Where did you find that property ? On which class ?

I can't find it in the doc.

Thanks,

MM

|||

LockType = adLockOptimistic

google will give you some good material on this.

http://support.microsoft.com/default.aspx/kb/281998

Adamus

ODBC & Multi-threading

I'm working on a C# (2005) app that requires shooting a large number of queries via Odbc, wait until the last one is done and then compute an overall result.

Since the queries are not interdependent, I would like to get them to run concurrently on multiple threads.

I did manage to get several queries run on different threads but the response time for the same query varies dramatically when another query is running concurently (even on a different ODBC connection). All is as if something was queing those queries regardless of the threads and/or the connection objects being used.

Basically when I run a very simple query q1 (thread 1 connection1) on its own, the result is instantaneous, but if I first start a big query q2 (thread 2, connection 2) and then q1 while q2 is running q1 takes forever.

Is it possible at all (for example, does the Odbc driver support being used that way)

Any suggestion as to how to handle that problem would be appreciated.

MM

I do not see why it could not be done. Miltithreading is basically the same as multiple connections from different clients at same time and it is definitely allowed. First it is quite possible that your first thread blocks another one until it finishes execution. In this case second block is doing nothing and just waits. Another potential issue is your big query is so *heavy* for the server that sever just uses 100% of its resources for this query. But I am doubt that this is the case|||

Are you using (nolocks) on your tables?

Select * from Customers (nolock)

Where yada yada yada

If you are not, one query is locking the table until the connection closes.

This is how it works:

1. Query1 --> Select * from Customers

Customers Table is locked until connection closes|||

Yes, I have no doubt that from a server standpoint there is no problem.

The question was more whether multiple queries running simultaneously from the same client machine may be a problem.

For example what if the ODBC driver queues the queries.

I read somewhere that depending on the provider some drivers may or may not support multithreading but have no ide whether it's true or if it has anything to do with my problem.

Thanks anyway,

MM

|||

Adamus,

Good thought, it may be the cause of my problem.

I did try shooting the queries at different tables and it seemed to work fine.

a- Now, for the (nolock); I believe this is a SQL Server specific syntax, do you know if there's a generic way to issue a 'dirty read' through ODBC without being tied to the syntax of particular vendor/DB ?

Would starting a transaction from the ODBCConnection used for the command and set its isolationlevel to 'UncommitedRead' work ?

b- Assuming there's a way of doing a dirty read. Any suggestion as to how best handle the following ? :

- Do first select and get a list of values

- For each of the values issue a scalar command and get the result

- Once all the results are collected, do something with them and display the final result.

The trick of course is to create as many threads are scalar commands to be issued since it would improve perfs to run them in parallel. But it has to be done dynamically since we don't know how many we'll get. Then we need the ability to tie everything back together. Not exactly obvious to do, at least to me.

Thanks,

MM

|||

ODBC? Kind of unfamiliar ground for me unfortunately. (I'm more of a SQL guy)The first thing that comes to mind is .LockType

...but good luck :)

Adamus

|||

.Locktype ? Where did you find that property ? On which class ?

I can't find it in the doc.

Thanks,

MM

|||

LockType = adLockOptimistic

google will give you some good material on this.

http://support.microsoft.com/default.aspx/kb/281998

Adamus

Monday, February 20, 2012

object_id function returns null

Hello,
I've been using object_id(object_name) function in some queries to retrieve
tables' ids without problems. However, those queries have started to fail
because object_id function returns null when the table name is like this one:
'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
and it has a valid id.
Any idea how to solve this? What are my options? Should I rewrite my queries
and use sysobject.name to perform JOINs?
I'm using SQL Server 2000.
Thanks in advance.
Is "MyPrefix" part of the table name or is it the owner of the table. If the former, you need to
quote it in OBJECT_ID, just the same way as when you refer to the table in a SELECT statement. But
the recommendation is to stick within the limits of standard identifiers when you name objects
(which among other thing doesn't allow a dot in the name):
CREATE TABLE "My.Table"(c1 int)
--Returns NULL, SQL Server assumes "My" is the owner
SELECT OBJECT_ID('My.Table')
--Returns the object id
SELECT OBJECT_ID('"My.Table"')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
news:75E956AC-BC7F-4A77-A149-3C0AD2B3E220@.microsoft.com...
> Hello,
> I've been using object_id(object_name) function in some queries to retrieve
> tables' ids without problems. However, those queries have started to fail
> because object_id function returns null when the table name is like this one:
> 'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
> and it has a valid id.
> Any idea how to solve this? What are my options? Should I rewrite my queries
> and use sysobject.name to perform JOINs?
> I'm using SQL Server 2000.
> Thanks in advance.
|||Thank you very much for you help. It works as you said.
I'm experiencing the issue in a customer's database.
Do you think it's safe to replace every call to object_id(table_name) with
object_id('"' + table_name + '"') or do you think I could face any collateral
effect?
Thanks again.
"Tibor Karaszi" wrote:

> Is "MyPrefix" part of the table name or is it the owner of the table. If the former, you need to
> quote it in OBJECT_ID, just the same way as when you refer to the table in a SELECT statement. But
> the recommendation is to stick within the limits of standard identifiers when you name objects
> (which among other thing doesn't allow a dot in the name):
> CREATE TABLE "My.Table"(c1 int)
> --Returns NULL, SQL Server assumes "My" is the owner
> SELECT OBJECT_ID('My.Table')
> --Returns the object id
> SELECT OBJECT_ID('"My.Table"')
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
> news:75E956AC-BC7F-4A77-A149-3C0AD2B3E220@.microsoft.com...
>
|||> Do you think it's safe to replace every call to object_id(table_name) with
> object_id('"' + table_name + '"') or do you think I could face any collateral
> effect?
It depends. If the "object_name" part has the owner in it, you can't just quote the whole lot, you'd
have to quote each part:
CREATE TABLE "theTable"(c1 int)
--Returns object id
SELECT OBJECT_ID('"theTable"')
--Returns NULL
SELECT OBJECT_ID('"dbo.Table"')
--Should be
SELECT OBJECT_ID('"dbo"."Table"')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
news:6311228F-E9CD-4304-A3EE-292FAD6E6FFA@.microsoft.com...[vbcol=seagreen]
> Thank you very much for you help. It works as you said.
> I'm experiencing the issue in a customer's database.
> Do you think it's safe to replace every call to object_id(table_name) with
> object_id('"' + table_name + '"') or do you think I could face any collateral
> effect?
> Thanks again.
>
> "Tibor Karaszi" wrote:

object_id function returns null

Hello,
I've been using object_id(object_name) function in some queries to retrieve
tables' ids without problems. However, those queries have started to fail
because object_id function returns null when the table name is like this one:
'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
and it has a valid id.
Any idea how to solve this? What are my options? Should I rewrite my queries
and use sysobject.name to perform JOINs?
I'm using SQL Server 2000.
Thanks in advance.Thank you very much for you help. It works as you said.
I'm experiencing the issue in a customer's database.
Do you think it's safe to replace every call to object_id(table_name) with
object_id('"' + table_name + '"') or do you think I could face any collateral
effect?
Thanks again.
"Tibor Karaszi" wrote:
> Is "MyPrefix" part of the table name or is it the owner of the table. If the former, you need to
> quote it in OBJECT_ID, just the same way as when you refer to the table in a SELECT statement. But
> the recommendation is to stick within the limits of standard identifiers when you name objects
> (which among other thing doesn't allow a dot in the name):
> CREATE TABLE "My.Table"(c1 int)
> --Returns NULL, SQL Server assumes "My" is the owner
> SELECT OBJECT_ID('My.Table')
> --Returns the object id
> SELECT OBJECT_ID('"My.Table"')
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
> news:75E956AC-BC7F-4A77-A149-3C0AD2B3E220@.microsoft.com...
> > Hello,
> >
> > I've been using object_id(object_name) function in some queries to retrieve
> > tables' ids without problems. However, those queries have started to fail
> > because object_id function returns null when the table name is like this one:
> > 'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
> > and it has a valid id.
> >
> > Any idea how to solve this? What are my options? Should I rewrite my queries
> > and use sysobject.name to perform JOINs?
> >
> > I'm using SQL Server 2000.
> >
> > Thanks in advance.
>|||Is "MyPrefix" part of the table name or is it the owner of the table. If the former, you need to
quote it in OBJECT_ID, just the same way as when you refer to the table in a SELECT statement. But
the recommendation is to stick within the limits of standard identifiers when you name objects
(which among other thing doesn't allow a dot in the name):
CREATE TABLE "My.Table"(c1 int)
--Returns NULL, SQL Server assumes "My" is the owner
SELECT OBJECT_ID('My.Table')
--Returns the object id
SELECT OBJECT_ID('"My.Table"')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
news:75E956AC-BC7F-4A77-A149-3C0AD2B3E220@.microsoft.com...
> Hello,
> I've been using object_id(object_name) function in some queries to retrieve
> tables' ids without problems. However, those queries have started to fail
> because object_id function returns null when the table name is like this one:
> 'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
> and it has a valid id.
> Any idea how to solve this? What are my options? Should I rewrite my queries
> and use sysobject.name to perform JOINs?
> I'm using SQL Server 2000.
> Thanks in advance.|||> Do you think it's safe to replace every call to object_id(table_name) with
> object_id('"' + table_name + '"') or do you think I could face any collateral
> effect?
It depends. If the "object_name" part has the owner in it, you can't just quote the whole lot, you'd
have to quote each part:
CREATE TABLE "theTable"(c1 int)
--Returns object id
SELECT OBJECT_ID('"theTable"')
--Returns NULL
SELECT OBJECT_ID('"dbo.Table"')
--Should be
SELECT OBJECT_ID('"dbo"."Table"')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
news:6311228F-E9CD-4304-A3EE-292FAD6E6FFA@.microsoft.com...
> Thank you very much for you help. It works as you said.
> I'm experiencing the issue in a customer's database.
> Do you think it's safe to replace every call to object_id(table_name) with
> object_id('"' + table_name + '"') or do you think I could face any collateral
> effect?
> Thanks again.
>
> "Tibor Karaszi" wrote:
>> Is "MyPrefix" part of the table name or is it the owner of the table. If the former, you need to
>> quote it in OBJECT_ID, just the same way as when you refer to the table in a SELECT statement.
>> But
>> the recommendation is to stick within the limits of standard identifiers when you name objects
>> (which among other thing doesn't allow a dot in the name):
>> CREATE TABLE "My.Table"(c1 int)
>> --Returns NULL, SQL Server assumes "My" is the owner
>> SELECT OBJECT_ID('My.Table')
>> --Returns the object id
>> SELECT OBJECT_ID('"My.Table"')
>>
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>> Blog: http://solidqualitylearning.com/blogs/tibor/
>>
>> "Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
>> news:75E956AC-BC7F-4A77-A149-3C0AD2B3E220@.microsoft.com...
>> > Hello,
>> >
>> > I've been using object_id(object_name) function in some queries to retrieve
>> > tables' ids without problems. However, those queries have started to fail
>> > because object_id function returns null when the table name is like this one:
>> > 'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
>> > and it has a valid id.
>> >
>> > Any idea how to solve this? What are my options? Should I rewrite my queries
>> > and use sysobject.name to perform JOINs?
>> >
>> > I'm using SQL Server 2000.
>> >
>> > Thanks in advance.
>>|||So the name of the table if MyPrefix.SomeTable, therefore MyPrefix is
not the owner right ? Normally, it is supposed to be the owner rather
than part of the name. Anyway, try to use the command with putting the
name in brackets.
OBJECT_ID('[MyPrefix.SampleTable]')
HTH, Jens Suessmeyer.
--
http://www.sqlserver2005.de
--

object_id function returns null

Hello,
I've been using object_id(object_name) function in some queries to retrieve
tables' ids without problems. However, those queries have started to fail
because object_id function returns null when the table name is like this one
:
'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
and it has a valid id.
Any idea how to solve this? What are my options? Should I rewrite my queries
and use sysobject.name to perform JOINs?
I'm using SQL Server 2000.
Thanks in advance.Is "MyPrefix" part of the table name or is it the owner of the table. If the
former, you need to
quote it in OBJECT_ID, just the same way as when you refer to the table in a
SELECT statement. But
the recommendation is to stick within the limits of standard identifiers whe
n you name objects
(which among other thing doesn't allow a dot in the name):
CREATE TABLE "My.Table"(c1 int)
--Returns NULL, SQL Server assumes "My" is the owner
SELECT OBJECT_ID('My.Table')
--Returns the object id
SELECT OBJECT_ID('"My.Table"')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
news:75E956AC-BC7F-4A77-A149-3C0AD2B3E220@.microsoft.com...
> Hello,
> I've been using object_id(object_name) function in some queries to retriev
e
> tables' ids without problems. However, those queries have started to fail
> because object_id function returns null when the table name is like this o
ne:
> 'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
> and it has a valid id.
> Any idea how to solve this? What are my options? Should I rewrite my queri
es
> and use sysobject.name to perform JOINs?
> I'm using SQL Server 2000.
> Thanks in advance.|||Thank you very much for you help. It works as you said.
I'm experiencing the issue in a customer's database.
Do you think it's safe to replace every call to object_id(table_name) with
object_id('"' + table_name + '"') or do you think I could face any collatera
l
effect?
Thanks again.
"Tibor Karaszi" wrote:

> Is "MyPrefix" part of the table name or is it the owner of the table. If t
he former, you need to
> quote it in OBJECT_ID, just the same way as when you refer to the table in
a SELECT statement. But
> the recommendation is to stick within the limits of standard identifiers w
hen you name objects
> (which among other thing doesn't allow a dot in the name):
> CREATE TABLE "My.Table"(c1 int)
> --Returns NULL, SQL Server assumes "My" is the owner
> SELECT OBJECT_ID('My.Table')
> --Returns the object id
> SELECT OBJECT_ID('"My.Table"')
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
> news:75E956AC-BC7F-4A77-A149-3C0AD2B3E220@.microsoft.com...
>|||> Do you think it's safe to replace every call to object_id(table_name) with
> object_id('"' + table_name + '"') or do you think I could face any collate
ral
> effect?
It depends. If the "object_name" part has the owner in it, you can't just qu
ote the whole lot, you'd
have to quote each part:
CREATE TABLE "theTable"(c1 int)
--Returns object id
SELECT OBJECT_ID('"theTable"')
--Returns NULL
SELECT OBJECT_ID('"dbo.Table"')
--Should be
SELECT OBJECT_ID('"dbo"."Table"')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
news:6311228F-E9CD-4304-A3EE-292FAD6E6FFA@.microsoft.com...[vbcol=seagreen]
> Thank you very much for you help. It works as you said.
> I'm experiencing the issue in a customer's database.
> Do you think it's safe to replace every call to object_id(table_name) with
> object_id('"' + table_name + '"') or do you think I could face any collate
ral
> effect?
> Thanks again.
>
> "Tibor Karaszi" wrote:
>

object_id function returns null

Hello,
I've been using object_id(object_name) function in some queries to retrieve
tables' ids without problems. However, those queries have started to fail
because object_id function returns null when the table name is like this one
:
'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
and it has a valid id.
Any idea how to solve this? What are my options? Should I rewrite my queries
and use sysobject.name to perform JOINs?
I'm using SQL Server 2000.
Thanks in advance.Is "MyPrefix" part of the table name or is it the owner of the table. If the
former, you need to
quote it in OBJECT_ID, just the same way as when you refer to the table in a
SELECT statement. But
the recommendation is to stick within the limits of standard identifiers whe
n you name objects
(which among other thing doesn't allow a dot in the name):
CREATE TABLE "My.Table"(c1 int)
--Returns NULL, SQL Server assumes "My" is the owner
SELECT OBJECT_ID('My.Table')
--Returns the object id
SELECT OBJECT_ID('"My.Table"')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
news:75E956AC-BC7F-4A77-A149-3C0AD2B3E220@.microsoft.com...
> Hello,
> I've been using object_id(object_name) function in some queries to retriev
e
> tables' ids without problems. However, those queries have started to fail
> because object_id function returns null when the table name is like this o
ne:
> 'MyPrefix.SampleTable'. I've checked sysobjects and the table exists there
> and it has a valid id.
> Any idea how to solve this? What are my options? Should I rewrite my queri
es
> and use sysobject.name to perform JOINs?
> I'm using SQL Server 2000.
> Thanks in advance.|||Thank you very much for you help. It works as you said.
I'm experiencing the issue in a customer's database.
Do you think it's safe to replace every call to object_id(table_name) with
object_id('"' + table_name + '"') or do you think I could face any collatera
l
effect?
Thanks again.
"Tibor Karaszi" wrote:

> Is "MyPrefix" part of the table name or is it the owner of the table. If t
he former, you need to
> quote it in OBJECT_ID, just the same way as when you refer to the table in
a SELECT statement. But
> the recommendation is to stick within the limits of standard identifiers w
hen you name objects
> (which among other thing doesn't allow a dot in the name):
> CREATE TABLE "My.Table"(c1 int)
> --Returns NULL, SQL Server assumes "My" is the owner
> SELECT OBJECT_ID('My.Table')
> --Returns the object id
> SELECT OBJECT_ID('"My.Table"')
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
> news:75E956AC-BC7F-4A77-A149-3C0AD2B3E220@.microsoft.com...
>|||> Do you think it's safe to replace every call to object_id(table_name) with
> object_id('"' + table_name + '"') or do you think I could face any collate
ral
> effect?
It depends. If the "object_name" part has the owner in it, you can't just qu
ote the whole lot, you'd
have to quote each part:
CREATE TABLE "theTable"(c1 int)
--Returns object id
SELECT OBJECT_ID('"theTable"')
--Returns NULL
SELECT OBJECT_ID('"dbo.Table"')
--Should be
SELECT OBJECT_ID('"dbo"."Table"')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jos G" <JGeer@.nospamplease.onobox.com> wrote in message
news:6311228F-E9CD-4304-A3EE-292FAD6E6FFA@.microsoft.com...
> Thank you very much for you help. It works as you said.
> I'm experiencing the issue in a customer's database.
> Do you think it's safe to replace every call to object_id(table_name) with
> object_id('"' + table_name + '"') or do you think I could face any collate
ral
> effect?
> Thanks again.
>
> "Tibor Karaszi" wrote:
>