473,597 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem With View and Changing Field Length

I had a strange situation with a view in SQL 7, that I could use some input
on.

I had a very simple view -- select a, b, c from table1 where x=y and z=q.
Field a in table1 originally was varchar 70. A long time ago I changed it to
varchar 95.

I used this view as an ODBC linked table in an Access MDB. Recently, there
was one row which has a value in field a that was more than 70 characters
long. This caused an error when the view as opened in the MDB file: "string
data, right truncation (#0)"

I went to the view in SQL Server, and displayed the row fine. So I delete
the link to the view in Access, compacted the Access database, and recreated
the link. Same results. The row showed #Error in the linked view, and the
message box with the truncation error would come up.

I went into SQL Server, took the SQL from the view and created a new view. I
linked the new view in Access, and it worked fine. No error.

So it seems that, somehow, view was holding onto the old field length, even
though it was using the new field length when displayed. But when the view
was linked, it used the old field length.

Is there something I could have or should have done short of recreating the
view? Any idea why the view used the old field length when it was linked,
but used the new field length when it was opened directly?

Thanks!

Neil
Jun 27 '08 #1
6 7039
Is there something I could have or should have done short of recreating
the view? Any idea why the view used the old field length when it was
linked, but used the new field length when it was opened directly?
View meta data are stored at the time the view is created so subsequent
changes to the underlying objects won't be reflected in the view. After
making changes to tables referenced by views, you'll need to either recreate
the views or execute sp_refreshview against the views to sync the meta data.

--
Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

"Neil" <no****@nospam. netwrote in message
news:hi******** ********@nlpi06 5.nbdc.sbc.com. ..
>I had a strange situation with a view in SQL 7, that I could use some input
on.

I had a very simple view -- select a, b, c from table1 where x=y and z=q.
Field a in table1 originally was varchar 70. A long time ago I changed it
to varchar 95.

I used this view as an ODBC linked table in an Access MDB. Recently, there
was one row which has a value in field a that was more than 70 characters
long. This caused an error when the view as opened in the MDB file:
"string data, right truncation (#0)"

I went to the view in SQL Server, and displayed the row fine. So I delete
the link to the view in Access, compacted the Access database, and
recreated the link. Same results. The row showed #Error in the linked
view, and the message box with the truncation error would come up.

I went into SQL Server, took the SQL from the view and created a new view.
I linked the new view in Access, and it worked fine. No error.

So it seems that, somehow, view was holding onto the old field length,
even though it was using the new field length when displayed. But when the
view was linked, it used the old field length.

Is there something I could have or should have done short of recreating
the view? Any idea why the view used the old field length when it was
linked, but used the new field length when it was opened directly?

Thanks!

Neil
Jun 27 '08 #2

"Dan Guzman" <gu******@nospa m-online.sbcgloba l.netwrote in message
news:u7******** ********@flpi15 0.ffdc.sbc.com. ..
>Is there something I could have or should have done short of recreating
the view? Any idea why the view used the old field length when it was
linked, but used the new field length when it was opened directly?

View meta data are stored at the time the view is created so subsequent
changes to the underlying objects won't be reflected in the view. After
making changes to tables referenced by views, you'll need to either
recreate the views or execute sp_refreshview against the views to sync the
meta data.
Thanks. Good to know. Is there a way to run sp_refreshview against all
views, sort of as a global refresh? Or is there a feature in EM that might
do this? Thanks.
Jun 27 '08 #3
Neil (no****@nospam. net) writes:
Thanks. Good to know. Is there a way to run sp_refreshview against all
views, sort of as a global refresh? Or is there a feature in EM that might
do this? Thanks.
SELECT 'EXEC sp_refreshview ' + quotename(name)
FROM sysobjects
WHERE type = 'V'

Copy result into a query window and run it.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 27 '08 #4
Thanks, Erland! Just curious, as more of a theoretical point: why, do you
suppose, SQL Server doesn't reset the metadata when a table's structure has
changed? Seems that if the table structure has changed, the old meta data is
no longer valid. So why not automatically change it?

Thanks.
"Erland Sommarskog" <es****@sommars kog.sewrote in message
news:Xn******** **************@ 127.0.0.1...
Neil (no****@nospam. net) writes:
>Thanks. Good to know. Is there a way to run sp_refreshview against all
views, sort of as a global refresh? Or is there a feature in EM that
might
do this? Thanks.

SELECT 'EXEC sp_refreshview ' + quotename(name)
FROM sysobjects
WHERE type = 'V'

Copy result into a query window and run it.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Jun 27 '08 #5
Neil (no****@nospam. net) writes:
Thanks, Erland! Just curious, as more of a theoretical point: why, do
you suppose, SQL Server doesn't reset the metadata when a table's
structure has changed? Seems that if the table structure has changed,
the old meta data is no longer valid. So why not automatically change
it?
I think my answer to that question is that you should put this
suggestion on Connect:
http://connect.microsoft.som/SqlServer/Feedback
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 27 '08 #6

"Erland Sommarskog" <es****@sommars kog.sewrote in message
news:Xn******** **************@ 127.0.0.1...
Neil (no****@nospam. net) writes:
>Thanks, Erland! Just curious, as more of a theoretical point: why, do
you suppose, SQL Server doesn't reset the metadata when a table's
structure has changed? Seems that if the table structure has changed,
the old meta data is no longer valid. So why not automatically change
it?

I think my answer to that question is that you should put this
suggestion on Connect:
http://connect.microsoft.som/SqlServer/Feedback
Ah, so it's not a question of some deep technological mystery, but more of a
deep MS mystery. :-) Thanks!
Jun 27 '08 #7

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

Similar topics

8
1827
by: Christopher Benson-Manica | last post by:
Why would this code... Date.prototype.addDays=function( days ) { this.setDate( this.getDate()+days ); } ....break the Date constructor? If I don't include it, everything is fine. If I do, alert( new Date() ); gives me an empty string. What in the holy heck gives? (Sorry - I just wasted half an hour tracking down a problem caused by changing an == null to an ===
20
2669
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...
2
1190
by: Sara | last post by:
The problem: Conditional formatting bold, red when field Value < date() sets the field background to white - always - whether condition is met or not. I want the field unfilled and just red/bold when the date has passed. Background: I have 2 related fields that are only rarely active, so I manage them in the query for the subform: ShowBlanket: IIf(,"Blanket","") and
4
3149
by: Mal Reeve | last post by:
Hello, I have a report that has only 2 levels of grouping. The detail section is simply 1 large block for a memo field. I am finding that on some occasions the report errors and generates hundreds (perhaps even an infinite loop...I have to break the system to stop the report generating) of pages. While I'm not 100% I think this may have something to do with the detail
10
3854
by: db2group88 | last post by:
hi, we are using db2 v8.2 EE on windows, with jcc driver. try to create a join view, after that i check the syscat.columns table, for those decimal field use COALESCE method, all the length become 11 instead of the actual length of the field inside table, can anyone explain this to me ? thank you create view ML101PD.ARJMBAL1 (ARNM05, ARNO01, ARNM01, ARNO07, ARNO08, ARNO09, ARFL17, ARFL03, ARMO12, ARDY12, ARCC12, ARYR12, ARNO15,...
3
1539
by: settyv | last post by:
Hi, I need to generate PDF stream when i click on Linkbutton in datagrid ..At present i hardcoded the DMS Id and now it is working.But i need to pass DMS ID when click linkbutton.How can i do that? Here is the ASPX code: <asp:datagrid id="grdTentativeResults" Width="800" Runat="server"
2
6967
by: John | last post by:
Hi Everyone, I have a question about dynamically changing the length of a varchar(n) field, in case the value I'm trying to insert is too big and will give a "truncated" error, but before the error is given! i.e. Is there some kind of a way to "test" the length of the field while Inserting the value into it, and to have it automatically increase its length to the length of the value being inserted, in case the value is too big? I've...
17
11696
by: radio1 | last post by:
Configuration: Access 2002 and SQL Server 2000 using a .ADP Project. I would VERY MUCH appreciate anyone's input into this problem I'm having. I have a form in Access that does not permit the user to add/change/delete any data, apparently as a result of adding a GROUP BY clause to a View used indirectly as the form's Record Source. I really don't believe that this restriction needs to be there, and I'm hoping that someone can suggest...
2
3143
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
0
7965
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7885
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8380
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
8031
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,...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3881
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
2399
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
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.