473,881 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with HOST_NAME Function with Linked View

I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
with 50,000 records; and I have a selections table with 50,000 records for
each machine that uses the database (about 25-50). This allows each user to
have their own set of selections.

The selections table has three fields: ID (int), Sel (bit), MachName
(varchar). ID and MachName comprise the primary key.

I have a view that combines the main table and the entries for the
selections table for the current machine (SQL below). The view works fine
when opened in EM and QA. And if I create a pass-through query from my
Access MDB file, the results are displayed fine.

However, if I link the view to the Access MDB file, I get "#Deleted" in
every field of every record (which seems to indicate that the records were
there and then they were gone). However, if I hard-code the machine name
into the same view instead of using HOST_NAME and then relink the view to
the MDB file, the linked view opens fine. Only when I use HOST_NAME as a
parameter in the view is there a problem with it.

Anyone have any idea what's going on here, or have heard of any issues with
HOST_NAME and ODBC linked objects? SQL for the view is below.

Thanks!

Neil

SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
FROM dbo.INVTRY INNER JOIN
dbo.InvtrySelec tions ON
dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())
Nov 13 '05 #1
23 1784
Neil wrote:
I have a view that combines the main table and the entries for the
selections table for the current machine (SQL below). The view works fine
when opened in EM and QA. And if I create a pass-through query from my
Access MDB file, the results are displayed fine.
HOST_NAME() is a T-SQL function. Enterprise Manager, Query Analyzer and
Access Pass-Through querys are direct interfaces to SQL Server and thus
T-SQL

However, if I link the view to the Access MDB file, I get "#Deleted" in
every field of every record (which seems to indicate that the records were
there and then they were gone). However, if I hard-code the machine name
into the same view instead of using HOST_NAME and then relink the view to
the MDB file, the linked view opens fine. Only when I use HOST_NAME as a
parameter in the view is there a problem with it.


Does this not imply that T-SQL cannot construct HOST_NAME() from
Access/Jet SQL?
Nov 13 '05 #2
First, you shouldn't crosspost to newsgroups not relevant to your problem.

Second, create a view that will simply select and display the value of
HOST_NAME() and you will you see if there is a problem with it and
SQL-Server 7 and a MDB file.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Neil" <no****@nospam. net> wrote in message
news:lr******** *********@newsr ead3.news.pas.e arthlink.net...
I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
with 50,000 records; and I have a selections table with 50,000 records for
each machine that uses the database (about 25-50). This allows each user to
have their own set of selections.

The selections table has three fields: ID (int), Sel (bit), MachName
(varchar). ID and MachName comprise the primary key.

I have a view that combines the main table and the entries for the
selections table for the current machine (SQL below). The view works fine
when opened in EM and QA. And if I create a pass-through query from my
Access MDB file, the results are displayed fine.

However, if I link the view to the Access MDB file, I get "#Deleted" in
every field of every record (which seems to indicate that the records were
there and then they were gone). However, if I hard-code the machine name
into the same view instead of using HOST_NAME and then relink the view to
the MDB file, the linked view opens fine. Only when I use HOST_NAME as a
parameter in the view is there a problem with it.

Anyone have any idea what's going on here, or have heard of any issues
with HOST_NAME and ODBC linked objects? SQL for the view is below.

Thanks!

Neil

SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
FROM dbo.INVTRY INNER JOIN
dbo.InvtrySelec tions ON
dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())

Nov 13 '05 #3
Neil (no****@nospam. net) writes:
SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
FROM dbo.INVTRY INNER JOIN
dbo.InvtrySelec tions ON
dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())


Now that I see the entire view, I repeat what I said before: make
MachName nvarchar, and put the clustered index on this column.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Nov 13 '05 #4
Ananda Sim (An*******@gmai l.com.invalid) writes:
Does this not imply that T-SQL cannot construct HOST_NAME() from
Access/Jet SQL?


Indeed, the host name must be set through the connection string. I don't
know how it works through Access, but the mechanism is such that the
client tells SQL Server about the name, and lie as much as it want.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Nov 13 '05 #5
Neil wrote:
I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
with 50,000 records; and I have a selections table with 50,000 records for
each machine that uses the database (about 25-50). This allows each user to
have their own set of selections.

The selections table has three fields: ID (int), Sel (bit), MachName
(varchar). ID and MachName comprise the primary key.

I have a view that combines the main table and the entries for the
selections table for the current machine (SQL below). The view works fine
when opened in EM and QA. And if I create a pass-through query from my
Access MDB file, the results are displayed fine.

However, if I link the view to the Access MDB file, I get "#Deleted" in
every field of every record (which seems to indicate that the records were
there and then they were gone). However, if I hard-code the machine name
into the same view instead of using HOST_NAME and then relink the view to
the MDB file, the linked view opens fine. Only when I use HOST_NAME as a
parameter in the view is there a problem with it.

Anyone have any idea what's going on here, or have heard of any issues with
HOST_NAME and ODBC linked objects? SQL for the view is below.


I've not had any problems with Host_name() as a parameter, as the only
records I retrieve are for my particular machine there is very little
point in returning that column so I never ask the server for it as I
know the value already.

A couple of things you need to know about Access and SQL Server, firstly
bit fields should be made NOT NULL and default to 0 as Access interprets
these as Jet Yes/No columns and treats them accordingly so it expects a
value to be there (In Access/Jet, a Yes/No column cannot be null and
defaults to 0). The results otherwise can be unpredictable.

Secondly, if you have any floating point columns in your data (including
datetime as these are stored as floating point numbers) then you most
probably need a timestamp column as floating point errors can cause the
#Deleted condition you describe.
Nov 13 '05 #6
Obscure footnote:
any floating point columns in your data (including
datetime as these are stored as floating point numbers)
SQL Server doesn't store datetime as double. Access does,
and the problem arises because of the rounding error in
the conversion between the Access version and the SQL
Server version, even when values are not 'stored' in Access
at all.

(david)

"Trevor Best" <no****@localho st.invalid> wrote in message
news:43******** *************@n ews.zen.co.uk.. . Neil wrote: ..> I've not had any problems with Host_name() as a parameter, as the only
records I retrieve are for my particular machine there is very little
point in returning that column so I never ask the server for it as I
know the value already.

A couple of things you need to know about Access and SQL Server, firstly
bit fields should be made NOT NULL and default to 0 as Access interprets
these as Jet Yes/No columns and treats them accordingly so it expects a
value to be there (In Access/Jet, a Yes/No column cannot be null and
defaults to 0). The results otherwise can be unpredictable.

Secondly, if you have any floating point columns in your data (including
datetime as these are stored as floating point numbers) then you most
probably need a timestamp column as floating point errors can cause the
#Deleted condition you describe.

Nov 13 '05 #7

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:uQ******** ******@TK2MSFTN GP10.phx.gbl...
First, you shouldn't crosspost to newsgroups not relevant to your problem.
I wasn't aware that I had done that.

Second, create a view that will simply select and display the value of
HOST_NAME() and you will you see if there is a problem with it and
SQL-Server 7 and a MDB file.
Good point. I created a view that returned the value of HOST_NAME(), and it
linked fine into the MDB. I also created a new table, gave it a two-field
PK, and used HOST_NAME() as a parameter for one of the fields in a view.
That view also linked and displayed records fine. (Didn't do a two-table
test, which would be similar to what I'm working with. But it shows that
HOST_NAME() works fine with MDB linked views.)

Neil


--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Neil" <no****@nospam. net> wrote in message
news:lr******** *********@newsr ead3.news.pas.e arthlink.net...
I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
with 50,000 records; and I have a selections table with 50,000 records for
each machine that uses the database (about 25-50). This allows each user
to have their own set of selections.

The selections table has three fields: ID (int), Sel (bit), MachName
(varchar). ID and MachName comprise the primary key.

I have a view that combines the main table and the entries for the
selections table for the current machine (SQL below). The view works fine
when opened in EM and QA. And if I create a pass-through query from my
Access MDB file, the results are displayed fine.

However, if I link the view to the Access MDB file, I get "#Deleted" in
every field of every record (which seems to indicate that the records
were there and then they were gone). However, if I hard-code the machine
name into the same view instead of using HOST_NAME and then relink the
view to the MDB file, the linked view opens fine. Only when I use
HOST_NAME as a parameter in the view is there a problem with it.

Anyone have any idea what's going on here, or have heard of any issues
with HOST_NAME and ODBC linked objects? SQL for the view is below.

Thanks!

Neil

SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
FROM dbo.INVTRY INNER JOIN
dbo.InvtrySelec tions ON
dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())


Nov 13 '05 #8
After I got your note I did go ahead and make MachName nchar, as BOL says
that HOST_NAME() returns that type, and the sample it showed of storing its
return value in a table used an nchar(30) field.

The InvtrySelection s table had the PK (ID/MachName) as the clustered index.
I created a second index on MachName alone, and it made it the clustered
index.

With the above two changes, the results were the same. Still getting
"#Deleted".

Neil
"Erland Sommarskog" <es****@sommars kog.se> wrote in message
news:Xn******** *************@1 27.0.0.1...
Neil (no****@nospam. net) writes:
SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
FROM dbo.INVTRY INNER JOIN
dbo.InvtrySelec tions ON
dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())


Now that I see the entire view, I repeat what I said before: make
MachName nvarchar, and put the clustered index on this column.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Nov 13 '05 #9
"Ananda Sim" <An*******@gmai l.com.invalid> wrote in message
news:43******** *************** @news.optusnet. com.au...
Neil wrote:
I have a view that combines the main table and the entries for the
selections table for the current machine (SQL below). The view works fine
when opened in EM and QA. And if I create a pass-through query from my
Access MDB file, the results are displayed fine.


HOST_NAME() is a T-SQL function. Enterprise Manager, Query Analyzer and
Access Pass-Through querys are direct interfaces to SQL Server and thus
T-SQL

However, if I link the view to the Access MDB file, I get "#Deleted" in
every field of every record (which seems to indicate that the records
were there and then they were gone). However, if I hard-code the machine
name into the same view instead of using HOST_NAME and then relink the
view to the MDB file, the linked view opens fine. Only when I use
HOST_NAME as a parameter in the view is there a problem with it.


Does this not imply that T-SQL cannot construct HOST_NAME() from
Access/Jet SQL?


In a test, I created a view that returned the HOST_NAME() value, and another
view that used HOST_NAME() as a parameter. Both worked fine when linked to
the MDB file, so the problem's not with T-SQL not being able to construct
HOST_NAME from Jet SQL.

Neil
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3389
by: Lauren Quantrell | last post by:
I did this thing with host_name(). I'm hoping someone can tell me if I'm gonna get into trouble with this scheme before it's too late... I have maybe 75 users. They all call on a table of appointments (many thousands) and I dump the ones being viewed into a temp table named TaskTEMP. I am using a custom function within a View to grab a bunch of rows in one table and slap them into a single column on the records returned by the view....
20
2701
by: Neil | last post by:
I have an Access 2000 MDB file with a SQL 7 back end. I have a main table with 50,000 records; and I have a selections table with 50,000 records for each machine that uses the database (about 25-50). This allows each user to have their own set of selections. The selections table has three fields: ID (int), Sel (bit), MachName (varchar). ID and MachName comprise the primary key. I have a view that combines the main table and the entries...
0
10716
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10812
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10399
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9552
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7108
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5780
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.