Friday, March 30, 2012
Manage Triggers grayed out
Is there a way to give them access to view triggers via EM, but disable their ability to create/drop?
You need to be table owner or higher for this. And you cannot grant table owner in 2000. In other
words, either be the owner of the table or db_owner (you could try db_ddladmin, not sure). Whether
EM then will enable the option or not, I don't know...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"JLS" <jlshoop@.hotmail.com> wrote in message news:eoNMiiW5FHA.620@.TK2MSFTNGP12.phx.gbl...
What do I need to do to give someone access to Manage Triggers in EM?
Is there a way to give them access to view triggers via EM, but disable their ability to
create/drop?
Manage Triggers grayed out
Is there a way to give them access to view triggers via EM, but disable thei
r ability to create/drop?You need to be table owner or higher for this. And you cannot grant table ow
ner in 2000. In other
words, either be the owner of the table or db_owner (you could try db_ddladm
in, not sure). Whether
EM then will enable the option or not, I don't know...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"JLS" <jlshoop@.hotmail.com> wrote in message news:eoNMiiW5FHA.620@.TK2MSFTNGP
12.phx.gbl...
What do I need to do to give someone access to Manage Triggers in EM?
Is there a way to give them access to view triggers via EM, but disable thei
r ability to
create/drop?
Monday, March 26, 2012
Making field read only
Goodday all
I have a details view on a vb form .
Now that i have been working on the program , i realise that i would like to make some fields " read only '
Is that possible , and if so how?
Thanks
Rob
You could:
1 - Set permissions in SQL Server for SELECT only.
2. -Set the form properties to 'Read Only' (Enabled = False) for that textbox.
Making better queries
I am in process of reworking a web application, that is quite data-base
intensive. Right now I am focused on the view that executes the highest
number of queries. Telling you the full picture would be very verbose - the
database structure is quite compex, etc. What I am looking for, is some kind
of buide, how to write a better queries. Why one approach is better than the
other.
For example, the decisions I face, are:
- What is the most effective way to get only subset of records from ordered
query where are tens of thousands elements? I need this to enable paging
through the recordset.
- Why executing many queries like "SELECT myField FROM myTable WHERE
id=nn", just changing nn, sometimes is faster than creating a query with
subquery like "SELECT (SELECT myField FROM myTable WHERE id=outTable.id)
FROM outTable where id in (...)"
- Or, perhaps, alternative to subquery is a join, like in "SELECT * FROM
outTable LEFT JOIN myTable ON outTable.id=myTable.id WHERE outTable.id in
(...)"
Well, I am sure there is no short answer to questions like this, therefore I
need some wisdom, maybe there is some online article about this? I came to
conclusion that I need serious theory to complete my work, because my local
SQL server here executes my "improved" queries faster than the old, but the
SQL server of the webhoster executes them slower than the old ones. It
escapes me, why there should be such a difference, given that the data and
indexes are exactly the same on the two databases.
I will be gratefuly for any hint.
Pavils>What is the most effective way to get only subset of records from ordered
>query where are tens of thousands elements? I need this to enable paging
>through the recordset.
> - Why executing many queries like "SELECT myField FROM myTable WHERE
>id=nn", just changing nn, sometimes is faster than creating a query with
>subquery like "SELECT (SELECT myField FROM myTable WHERE id=outTable.id)
>FROM outTable where id in (...)"
>- Or, perhaps, alternative to subquery is a join, like in "SELECT * FROM
>outTable LEFT JOIN myTable ON outTable.id=myTable.id WHERE outTable.id in
>(...)"
I'd say it depends on what your trying to accomplish. The frist query
is the fastest and the last query is good if the join is needed.
Otherwise don't use joins if you don't need too, unless necessary, try
to use inner joins.
Other considerations too look at when comparing performance of the two
servers is memory, hard drive types and speeds, location, cpu speed and
server load.|||Have you looked at the execution plan for each of the queries. that will
tell you what SQL Server is doing behind the scenes, which will tell you
which query is the most efficient to run.
"Izzy" wrote:
>
> I'd say it depends on what your trying to accomplish. The frist query
> is the fastest and the last query is good if the join is needed.
> Otherwise don't use joins if you don't need too, unless necessary, try
> to use inner joins.
> Other considerations too look at when comparing performance of the two
> servers is memory, hard drive types and speeds, location, cpu speed and
> server load.
>
Making better queries
I am in process of reworking a web application, that is quite data-base
intensive. Right now I am focused on the view that executes the highest
number of queries. Telling you the full picture would be very verbose - the
database structure is quite compex, etc. What I am looking for, is some kind
of buide, how to write a better queries. Why one approach is better than the
other.
For example, the decisions I face, are:
- What is the most effective way to get only subset of records from ordered
query where are tens of thousands elements? I need this to enable paging
through the recordset.
- Why executing many queries like "SELECT myField FROM myTable WHERE
id=nn", just changing nn, sometimes is faster than creating a query with
subquery like "SELECT (SELECT myField FROM myTable WHERE id=outTable.id)
FROM outTable where id in (...)"
- Or, perhaps, alternative to subquery is a join, like in "SELECT * FROM
outTable LEFT JOIN myTable ON outTable.id=myTable.id WHERE outTable.id in
(...)"
Well, I am sure there is no short answer to questions like this, therefore I
need some wisdom, maybe there is some online article about this? I came to
conclusion that I need serious theory to complete my work, because my local
SQL server here executes my "improved" queries faster than the old, but the
SQL server of the webhoster executes them slower than the old ones. It
escapes me, why there should be such a difference, given that the data and
indexes are exactly the same on the two databases.
I will be gratefuly for any hint.
Pavils>What is the most effective way to get only subset of records from ordered
>query where are tens of thousands elements? I need this to enable paging
>through the recordset.
> - Why executing many queries like "SELECT myField FROM myTable WHERE
>id=nn", just changing nn, sometimes is faster than creating a query with
>subquery like "SELECT (SELECT myField FROM myTable WHERE id=outTable.id)
>FROM outTable where id in (...)"
>- Or, perhaps, alternative to subquery is a join, like in "SELECT * FROM
>outTable LEFT JOIN myTable ON outTable.id=myTable.id WHERE outTable.id in
>(...)"
I'd say it depends on what your trying to accomplish. The frist query
is the fastest and the last query is good if the join is needed.
Otherwise don't use joins if you don't need too, unless necessary, try
to use inner joins.
Other considerations too look at when comparing performance of the two
servers is memory, hard drive types and speeds, location, cpu speed and
server load.|||Have you looked at the execution plan for each of the queries. that will
tell you what SQL Server is doing behind the scenes, which will tell you
which query is the most efficient to run.
"Izzy" wrote:
> >What is the most effective way to get only subset of records from ordered
> >query where are tens of thousands elements? I need this to enable paging
> >through the recordset.
> > - Why executing many queries like "SELECT myField FROM myTable WHERE
> >id=nn", just changing nn, sometimes is faster than creating a query with
> >subquery like "SELECT (SELECT myField FROM myTable WHERE id=outTable.id)
> >FROM outTable where id in (...)"
> >- Or, perhaps, alternative to subquery is a join, like in "SELECT * FROM
> >outTable LEFT JOIN myTable ON outTable.id=myTable.id WHERE outTable.id in
> >(...)"
>
> I'd say it depends on what your trying to accomplish. The frist query
> is the fastest and the last query is good if the join is needed.
> Otherwise don't use joins if you don't need too, unless necessary, try
> to use inner joins.
> Other considerations too look at when comparing performance of the two
> servers is memory, hard drive types and speeds, location, cpu speed and
> server load.
>
Friday, March 23, 2012
Making a view that shows the results of several different queries.
I am trying to create a view that shows the following
Field1: Sum of Amounts from Table A
Field2: Count of Amounts from Table A
Field3: Sum of of Amounts from Table B
Field4: Count of Amounts from Table B
..
..
..
Field3: Sum of of Amounts from Table H
Field4: Count of Amounts from Table H
..
..
..
Things are a bit more complex but this is the gist.
I am using SQL 2000.
I know how to do this pretty easily using a stored procedure. But how
can I do it in a view? A SQL server won't meet my needs in this
situation.
I tried OpenQuery ('myserver', 'exec myprocedure') but get the message
that my server is not configured for data access. I tried the system
stored procedure to set data access to true but nothing seemed to
happen.
I also tried Select * from (
Select Statement1, select statement2
)
but got syntax error at the comma between statement1 and statement2.
Trying to use select Statement1 as ABC to does not seem to work either.
Is there a way to do what I want without making 15 views and then a
final view that shows them all together? I know I could probably do
something by creating a ton of functions, but it really seems this
should not be that hard...
I am definitely open to any easy suggestions!
Thanks,
RyanOn 21 Dec 2005 13:51:38 -0800, Ryan wrote:
>Hello,
>I am trying to create a view that shows the following
>Field1: Sum of Amounts from Table A
>Field2: Count of Amounts from Table A
>Field3: Sum of of Amounts from Table B
>Field4: Count of Amounts from Table B
>.
>.
>.
>Field3: Sum of of Amounts from Table H
>Field4: Count of Amounts from Table H
>.
>.
>.
>Things are a bit more complex but this is the gist.
>I am using SQL 2000.
>I know how to do this pretty easily using a stored procedure. But how
>can I do it in a view? A SQL server won't meet my needs in this
>situation.
Hi Ryan,
This can be done in a single query. You can of course encapsulate that
in a view, stored procedure, or whatever.
To prevent double table-scanning, here's a query that will scan each
table only once:
SELECT Field1, Field2, Field3, ..., Field16
FROM (SELECT SUM(Amount) AS Field1, COUNT(Amount) AS Field2
FROM TableA) AS A
CROSS JOIN (SELECT SUM(Amount) AS Field3, COUNT(Amount) AS Field4
FROM TableB) AS B
....
CROSS JOIN (SELECT SUM(Amount) AS Field15, COUNT(Amount) AS Field16
FROM TableH) AS H
(untested - see www.aspfaq.com/5006 if you prefer a tested reply)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||I have tried what you suggested but it seems to snag with Syntax
errors. SQL accepts my Select ... AS A, B, C if I use it with the
Select * construct but it does not accept the CROSS JOIN STATEMENT
Select * FROM
(
SELECT count(Amount) as count1, sum(Amount) as sum1
FROM mytable1
WHERE x="1" and y="2"...
)
AS A
CROSS JOIN
Select * FROM
(
SELECT count(Amount) as count1, sum(Amount) as sum1
FROM mytable1
WHERE x="1" and y="2" and some other stuff...
)
AS B
Any ideas? I am not sure why the CROSS JOIN won't work actually. It
error out as soon as it hits the SELECT statement that follows CROSS
JOIN...|||On 21 Dec 2005 16:58:18 -0800, Ryan wrote:
>I have tried what you suggested but it seems to snag with Syntax
>errors. SQL accepts my Select ... AS A, B, C if I use it with the
>Select * construct but it does not accept the CROSS JOIN STATEMENT
Hi Ryan,
You didn't use the correct syntax. Check my previous replly and compare
it carefully with your query.
>Select * FROM
>(
>SELECT count(Amount) as count1, sum(Amount) as sum1
>FROM mytable1
>WHERE x="1" and y="2"...
>)
>AS A
>CROSS JOIN
Remove the line below!
>Select * FROM
>(
>SELECT count(Amount) as count1, sum(Amount) as sum1
>FROM mytable1
>WHERE x="1" and y="2" and some other stuff...
>)
>AS B
>Any ideas? I am not sure why the CROSS JOIN won't work actually. It
>error out as soon as it hits the SELECT statement that follows CROSS
>JOIN...
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
making a view from the other server
hi
I have two sql servers in the LAN, one is 2000 and the other is 2005. in 2005 server I have a database and I want to have a view of a table in a database in the other server (2000) is it possible?
thank you in advance
Did you used Linked servers (see Books Online) ?
|||thank you for your answer,I will check but what should I do if they are not
|||another way is OPENROWSET but if this table is importan i should think to import it periodically depends on your business logic|||Just in case you are hitting brick wall of errors with linked server, refer to http://blogs.msdn.com/sqltips/archive/2005/06/07/426578.aspxmaking a view from the other server
hi
I have two sql servers in the LAN, one is 2000 and the other is 2005. in 2005 server I have a database and I want to have a view of a table in a database in the other server (2000) is it possible?
thank you in advance
Did you used Linked servers (see Books Online) ?
|||thank you for your answer,I will check but what should I do if they are not
|||another way is OPENROWSET but if this table is importan i should think to import it periodically depends on your business logic|||Just in case you are hitting brick wall of errors with linked server, refer to http://blogs.msdn.com/sqltips/archive/2005/06/07/426578.aspxsqlMaking a view
Tech_ID and the most recent, non-null value of
TechWOProduct_WorksheetNumber. Thanks for any help -John
CREATE TABLE [tblTech] (
[Tech_ID] [int] IDENTITY (1, 1) NOT NULL ,
[Tech_EID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL
)
CREATE TABLE [tblWO] (
[WO_ID] [int] IDENTITY (1, 1) NOT NULL ,
[WO_Date] [datetime] NULL
)
CREATE TABLE [tblTechWO] (
[TechWO_ID] [int] IDENTITY (1, 1) NOT NULL ,
[WO_ID] [int] NOT NULL ,
[Tech_ID] [int] NOT NULL
)
CREATE TABLE [tblTechWOProduct] (
[TechWOProduct_ID] [int] IDENTITY (1, 1) NOT NULL ,
[TechWO_ID] [int] NOT NULL ,
[TechWOProduct_Date] [datetime] NOT NULL ,
[TechWOProduct_WorksheetNumber] [int] NULL
)Hi, John
Besides DDL, it would have been useful if you would have provided
sample data and expected results. See:
http://www.aspfaq.com/etiquette.asp?id=5006
Your DDL is incomplete: it has no primary keys, no foreign keys and no
unique keys. If the DDL would have been complete we would know if it's
possible to have two rows in the tblTechWOProduct table with the same
TechWO_ID and TechWOProduct_Date. Because the DDL is incomplete, i must
ask you: is the above situation possible?
Anyway, assuming that the answer to the previous question is "no" (you
should create a unique constraint to ensure this), try the following
(not tested):
CREATE VIEW FirstView
AS
SELECT t.Tech_ID, p.TechWOProduct_Date, p.TechWOProduct_WorksheetNumber
FROM tblTechWO t INNER JOIN tblTechWOProduct p ON
t.TechWO_ID=p.TechWO_ID
WHERE TechWOProduct_WorksheetNumber IS NOT NULL
GO
CREATE VIEW YourView
AS
SELECT v.* FROM FirstView v
INNER JOIN (
SELECT Tech_ID, MAX(TechWOProduct_Date) AS MaxDate
FROM FirstView GROUP BY Tech_ID
) x ON v.Tech_ID=x.Tech_ID AND v.TechWOProduct_Date=x.MaxDate
Razvan
Making a dynamic table (view)?
contains like 4 years of records (1 record per day). Each record only has
that date in it. That's it. Simple enough, except I don't want this to be
a real table because it will be different day by day/year by year and it
needs to be relatively efficient. SQL2000.
What I have so far is:
begin
declare @.currdate SmallDateTime;
Set @.CurrDate='01/01/'+Cast(Year(GetDate())-1 as Char(4))
Create Table #temp(
aDate SmallDateTime
)
While year(@.CurrDate)<=Year(GetDate())+2
begin
Set @.CurrDate=DateAdd(d,1,@.CurrDate)
Insert Into #temp (aDate) values(@.CurrDate);
end
Select * from #Temp
Drop Table #Temp
end
The problem I see is the use of a temporary table and how that will impact
the server when it gets really loaded. Besides, this is just a procedure, I
need this to function "as if" it were a table to query against.
Any ideas?Why a temporary and not a real one?, you will not hurt your server for havin
g
one, instead, you can make life easier.
Why should I consider using an auxiliary calendar table?
http://www.aspfaq.com/show.asp?id=2519
AMB
"Jon Glazer" wrote:
> I would like to create a view or something that functions like a table tha
t
> contains like 4 years of records (1 record per day). Each record only has
> that date in it. That's it. Simple enough, except I don't want this to b
e
> a real table because it will be different day by day/year by year and it
> needs to be relatively efficient. SQL2000.
> What I have so far is:
> begin
> declare @.currdate SmallDateTime;
> Set @.CurrDate='01/01/'+Cast(Year(GetDate())-1 as Char(4))
> Create Table #temp(
> aDate SmallDateTime
> )
> While year(@.CurrDate)<=Year(GetDate())+2
> begin
> Set @.CurrDate=DateAdd(d,1,@.CurrDate)
> Insert Into #temp (aDate) values(@.CurrDate);
> end
> Select * from #Temp
> Drop Table #Temp
> end
> The problem I see is the use of a temporary table and how that will impact
> the server when it gets really loaded. Besides, this is just a procedure,
I
> need this to function "as if" it were a table to query against.
> Any ideas?
>
>|||Lets just say from a learning perspective, how would I achieve what I wish
to here?
Jon
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:5DC6B54C-311C-4E6E-A07B-1A864041DBE2@.microsoft.com...
> Why a temporary and not a real one?, you will not hurt your server for
> having
> one, instead, you can make life easier.
> Why should I consider using an auxiliary calendar table?
> http://www.aspfaq.com/show.asp?id=2519
>
> AMB
>
> "Jon Glazer" wrote:
>|||Why should I consider using an auxiliary numbers table?
http://www.aspfaq.com/show.asp?id=2516
Example:
use northwind
go
select
identity(int , 0, 1) as number
into
number
from
sysobjects as a
cross join
sysobjects as b
go
alter table number
add constraint pk_number primary key (number)
go
create function ufn_function1 (
@.sd datetime,
@.ed datetime
)
returns table
as
return (
select
dateadd(day, n.number, @.sd) as col_the_date
from
number as n
where
n.number <= datediff(day, @.sd, @.ed)
)
go
select
*
from
ufn_function1('20050128', '20050204')
order by
1
go
drop function ufn_function1
go
drop table number
go
AMB
"Jon Glazer" wrote:
> Lets just say from a learning perspective, how would I achieve what I wish
> to here?
> Jon
> "Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in messag
e
> news:5DC6B54C-311C-4E6E-A07B-1A864041DBE2@.microsoft.com...
>
>|||You can't generate data out of nothing. Two alternatives to using an actual
table would be to use a table-valued function containing a loop or to use a
view with a large UNION statement and one SELECT for each date. Either of
those structures would get materialized as data the moment they were used,
so they would offer no obvious benefits over using a table.
Auxiliary tables (Calendars, Numbers, etc) are a standard technique for
doing this sort of thing. After all, even 10 years of dates in a Calendar
table is still less than 4000 rows.
David Portas
SQL Server MVP
--|||If you must...
select
dateadd(year,- 1,dateadd(day,datediff(day,0,getdate()),
0)-datepart(dy,getdate
()))
+digit as dt
from (
select 1 + unit.digit +
10 * ten.digit +
100 * hundred.digit +
1000 * thousand.digit as [number]
from (
select 0 union select 1 union select 2 union select 3 union
select 4 union select 5 union select 6 union select 7 union
select 8 union select 9) as unit(digit)
cross join (
select 0 union select 1 union select 2 union select 3 union
select 4 union select 5 union select 6 union select 7 union
select 8 union select 9) as ten(digit)
cross join (
select 0 union select 1 union select 2 union select 3 union
select 4 union select 5 union select 6 union select 7 union
select 8 union select 9) as hundred(digit)
cross join (
select 0 union select 1 union select 2 ) as thousand(digit)
) numbers(digit)
where digit <= datediff(day,dateadd(year,-1,
dateadd(day,datediff(day,0,getdate()),0)
-datepart(dy,getdate()))
,dateadd(year,3,getdate()-datepart(dy,getdate())))
order by digit
-oj
"Jon Glazer" <jglazer.delete.me@.adconn.com> wrote in message
news:SoxKd.62801$re1.24174@.fe2.columbus.rr.com...
>I would like to create a view or something that functions like a table that
>contains like 4 years of records (1 record per day). Each record only has
>that date in it. That's it. Simple enough, except I don't want this to be
>a real table because it will be different day by day/year by year and it
>needs to be relatively efficient. SQL2000.
> What I have so far is:
> begin
> declare @.currdate SmallDateTime;
> Set @.CurrDate='01/01/'+Cast(Year(GetDate())-1 as Char(4))
> Create Table #temp(
> aDate SmallDateTime
> )
> While year(@.CurrDate)<=Year(GetDate())+2
> begin
> Set @.CurrDate=DateAdd(d,1,@.CurrDate)
> Insert Into #temp (aDate) values(@.CurrDate);
> end
> Select * from #Temp
> Drop Table #Temp
> end
> The problem I see is the use of a temporary table and how that will impact
> the server when it gets really loaded. Besides, this is just a procedure,
> I need this to function "as if" it were a table to query against.
> Any ideas?
>sql
Friday, March 9, 2012
major bug in SQL 2000
today I discovered a major and dangerous bug in SQL server. I've
created a view with many fields. When looking in the design manager
everything looks fine. However when I use the view, one of the column
headings is missing and the column names are shift to the left. The
values however are still on their own place. This results in a major
issue that the values appear under the wrong column. In design view
everything looks fine, but when you open the query it display the
wrong values. Thus:
In design view it looks like this:
Field1 Field2 Field3 Field4
1 2 3 4
When opening the query it looks like this:
Field1 Field3 Field4
1 2 3
How the hell is this possible. Changing one thing in the view saving
it again and then opneing it, everything is fine. But how do I know
which views are affected ?
Franc.I have screenshots available fot those interested. So far I've found 4
views which were affected. They were all based on the same tables. I
ran a dbcc checkdb and no error are reported on the database.
Franc.
>Hi,
>today I discovered a major and dangerous bug in SQL server. I've
>created a view with many fields. When looking in the design manager
>everything looks fine. However when I use the view, one of the column
>headings is missing and the column names are shift to the left. The
>values however are still on their own place. This results in a major
>issue that the values appear under the wrong column. In design view
>everything looks fine, but when you open the query it display the
>wrong values. Thus:
>In design view it looks like this:
>Field1 Field2 Field3 Field4
>1 2 3 4
>When opening the query it looks like this:
>Field1 Field3 Field4
>1 2 3
>How the hell is this possible. Changing one thing in the view saving
>it again and then opneing it, everything is fine. But how do I know
>which views are affected ?
>Franc.|||Can we see your code please.
J
>--Original Message--
>I have screenshots available fot those interested. So far
I've found 4
>views which were affected. They were all based on the
same tables. I
>ran a dbcc checkdb and no error are reported on the
database.
>Franc.
>
server. I've[vbcol=seagreen]
design manager[vbcol=seagreen]
of the column[vbcol=seagreen]
the left. The[vbcol=seagreen]
results in a major[vbcol=seagreen]
design view[vbcol=seagreen]
display the[vbcol=seagreen]
view saving[vbcol=seagreen]
how do I know[vbcol=seagreen]
>.
>|||Hi Franc
Are you altering the objects underneath the view? This can cause the
behaviour you're describing. That SQL Server lets you simply change objects
underneath views without warning is not great, but this isn't a bug as such.
You should look into using the SCHEMABINDING option in your CREATE VIEW
statements. This was designed to ensure that the objects that views
reference are not permitted to change underneath those views. That way, you
don't have to trawl through lists of dependent objects to make sure
everything is in synch..
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a34498.84859734@.msnews.microsoft.com...
> Hi,
> today I discovered a major and dangerous bug in SQL server. I've
> created a view with many fields. When looking in the design manager
> everything looks fine. However when I use the view, one of the column
> headings is missing and the column names are shift to the left. The
> values however are still on their own place. This results in a major
> issue that the values appear under the wrong column. In design view
> everything looks fine, but when you open the query it display the
> wrong values. Thus:
> In design view it looks like this:
> Field1 Field2 Field3 Field4
> 1 2 3 4
> When opening the query it looks like this:
> Field1 Field3 Field4
> 1 2 3
> How the hell is this possible. Changing one thing in the view saving
> it again and then opneing it, everything is fine. But how do I know
> which views are affected ?
> Franc.|||Hi,
this is the SQL statement I'm using:
SELECT TOP 100 PERCENT dbo.tblWoningen.*, dbo.Huren.*,
dbo.tblPuntenTotaal.*,
dbo.Woningen.Perceel AS Expr1
FROM dbo.Woningen LEFT OUTER JOIN
dbo.Huren ON
dbo.Woningen.Perceel = dbo.Huren.Perceelnr# LEFT
OUTER JOIN
dbo.tblPuntenTotaal ON dbo.Woningen.Perceel =
dbo.tblPuntenTotaal.VHE_nummer
ORDER BY dbo.Woningen.Perceel
Franc.
[vbcol=seagreen]
>Can we see your code please.
>J
>
>I've found 4
>same tables. I
>database.
>server. I've
>design manager
>of the column
>the left. The
>results in a major
>design view
>display the
>view saving
>how do I know|||Hi Greg,
no I haven't altered the tables below the views, only added data to
it. What I don't get is, why it looks correctly when run from design
view, but as soon as you run the view it goes wrong. After saving the
view from design view it displays the correct values again. Looks like
SQL is recompiling the view. Is there a way to force recompilation of
all view to ensure that everything is correct. Last week everything
worked fine, today we noticed that the wrong values appeared in field
on our mailing letters.
Franc.
On Thu, 13 May 2004 20:40:12 +1000, "Greg Linwood"
<g_linwoodQhotmail.com> wrote:
>Hi Franc
>Are you altering the objects underneath the view? This can cause the
>behaviour you're describing. That SQL Server lets you simply change objects
>underneath views without warning is not great, but this isn't a bug as such
.
>You should look into using the SCHEMABINDING option in your CREATE VIEW
>statements. This was designed to ensure that the objects that views
>reference are not permitted to change underneath those views. That way, you
>don't have to trawl through lists of dependent objects to make sure
>everything is in synch..
>Regards,
>Greg Linwood
>SQL Server MVP
>"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
>news:40a34498.84859734@.msnews.microsoft.com...
>|||Hi Franc
Using * in views is a bad idea. If the columns in the tables underneath the
view change, the view is not automatically updated. schemabinding would at
least help you by forcing the person who alters the columns in the
underlying tables to recompile the view.
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a35050.87859203@.msnews.microsoft.com...
> Hi,
> this is the SQL statement I'm using:
> SELECT TOP 100 PERCENT dbo.tblWoningen.*, dbo.Huren.*,
> dbo.tblPuntenTotaal.*,
> dbo.Woningen.Perceel AS Expr1
> FROM dbo.Woningen LEFT OUTER JOIN
> dbo.Huren ON
> dbo.Woningen.Perceel = dbo.Huren.Perceelnr# LEFT
> OUTER JOIN
> dbo.tblPuntenTotaal ON dbo.Woningen.Perceel =
> dbo.tblPuntenTotaal.VHE_nummer
> ORDER BY dbo.Woningen.Perceel
> Franc.
>
>|||Hi Franc
Sorry for repeating a little in this thread, but this is what schemabinding
is for. It forces the person who's altering the table / view underneath the
view to recompile the view at the time the underlying object is altered.
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a35148.88107390@.msnews.microsoft.com...
> Hi Greg,
> no I haven't altered the tables below the views, only added data to
> it. What I don't get is, why it looks correctly when run from design
> view, but as soon as you run the view it goes wrong. After saving the
> view from design view it displays the correct values again. Looks like
> SQL is recompiling the view. Is there a way to force recompilation of
> all view to ensure that everything is correct. Last week everything
> worked fine, today we noticed that the wrong values appeared in field
> on our mailing letters.
> Franc.
> On Thu, 13 May 2004 20:40:12 +1000, "Greg Linwood"
> <g_linwoodQhotmail.com> wrote:
>
objects[vbcol=seagreen]
such.[vbcol=seagreen]
you[vbcol=seagreen]
>|||If you post a complete repro script, we can try it on our SQL Servers and se
e if it reproduces...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a35050.87859203@.msnews.microsoft.com...
> Hi,
> this is the SQL statement I'm using:
> SELECT TOP 100 PERCENT dbo.tblWoningen.*, dbo.Huren.*,
> dbo.tblPuntenTotaal.*,
> dbo.Woningen.Perceel AS Expr1
> FROM dbo.Woningen LEFT OUTER JOIN
> dbo.Huren ON
> dbo.Woningen.Perceel = dbo.Huren.Perceelnr# LEFT
> OUTER JOIN
> dbo.tblPuntenTotaal ON dbo.Woningen.Perceel =
> dbo.tblPuntenTotaal.VHE_nummer
> ORDER BY dbo.Woningen.Perceel
> Franc.
>
>|||Hi Greg,
ok, I'll alter the view by using schemabindings. However, I don't get
why SQL just moves the column names and not the data. If it would
remove the data also it's fine. Now you get the wrong data in the
wrong columns whcih is much more dangerous.
Franc.
>Hi Franc
>Sorry for repeating a little in this thread, but this is what schemabinding
>is for. It forces the person who's altering the table / view underneath the
>view to recompile the view at the time the underlying object is altered.
>Regards,
>Greg Linwood
>SQL Server MVP
>"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
>news:40a35148.88107390@.msnews.microsoft.com...
>objects
>such.
>you
>
major bug in SQL 2000
today I discovered a major and dangerous bug in SQL server. I've
created a view with many fields. When looking in the design manager
everything looks fine. However when I use the view, one of the column
headings is missing and the column names are shift to the left. The
values however are still on their own place. This results in a major
issue that the values appear under the wrong column. In design view
everything looks fine, but when you open the query it display the
wrong values. Thus:
In design view it looks like this:
Field1 Field2 Field3 Field4
1 2 3 4
When opening the query it looks like this:
Field1 Field3 Field4
1 2 3
How the hell is this possible. Changing one thing in the view saving
it again and then opneing it, everything is fine. But how do I know
which views are affected ?
Franc.I have screenshots available fot those interested. So far I've found 4
views which were affected. They were all based on the same tables. I
ran a dbcc checkdb and no error are reported on the database.
Franc.
>Hi,
>today I discovered a major and dangerous bug in SQL server. I've
>created a view with many fields. When looking in the design manager
>everything looks fine. However when I use the view, one of the column
>headings is missing and the column names are shift to the left. The
>values however are still on their own place. This results in a major
>issue that the values appear under the wrong column. In design view
>everything looks fine, but when you open the query it display the
>wrong values. Thus:
>In design view it looks like this:
>Field1 Field2 Field3 Field4
>1 2 3 4
>When opening the query it looks like this:
>Field1 Field3 Field4
>1 2 3
>How the hell is this possible. Changing one thing in the view saving
>it again and then opneing it, everything is fine. But how do I know
>which views are affected ?
>Franc.|||Can we see your code please.
J
>--Original Message--
>I have screenshots available fot those interested. So far
I've found 4
>views which were affected. They were all based on the
same tables. I
>ran a dbcc checkdb and no error are reported on the
database.
>Franc.
>>Hi,
>>today I discovered a major and dangerous bug in SQL
server. I've
>>created a view with many fields. When looking in the
design manager
>>everything looks fine. However when I use the view, one
of the column
>>headings is missing and the column names are shift to
the left. The
>>values however are still on their own place. This
results in a major
>>issue that the values appear under the wrong column. In
design view
>>everything looks fine, but when you open the query it
display the
>>wrong values. Thus:
>>In design view it looks like this:
>>Field1 Field2 Field3 Field4
>>1 2 3 4
>>When opening the query it looks like this:
>>Field1 Field3 Field4
>>1 2 3
>>How the hell is this possible. Changing one thing in the
view saving
>>it again and then opneing it, everything is fine. But
how do I know
>>which views are affected ?
>>Franc.
>.
>|||Hi Franc
Are you altering the objects underneath the view? This can cause the
behaviour you're describing. That SQL Server lets you simply change objects
underneath views without warning is not great, but this isn't a bug as such.
You should look into using the SCHEMABINDING option in your CREATE VIEW
statements. This was designed to ensure that the objects that views
reference are not permitted to change underneath those views. That way, you
don't have to trawl through lists of dependent objects to make sure
everything is in synch..
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a34498.84859734@.msnews.microsoft.com...
> Hi,
> today I discovered a major and dangerous bug in SQL server. I've
> created a view with many fields. When looking in the design manager
> everything looks fine. However when I use the view, one of the column
> headings is missing and the column names are shift to the left. The
> values however are still on their own place. This results in a major
> issue that the values appear under the wrong column. In design view
> everything looks fine, but when you open the query it display the
> wrong values. Thus:
> In design view it looks like this:
> Field1 Field2 Field3 Field4
> 1 2 3 4
> When opening the query it looks like this:
> Field1 Field3 Field4
> 1 2 3
> How the hell is this possible. Changing one thing in the view saving
> it again and then opneing it, everything is fine. But how do I know
> which views are affected ?
> Franc.|||Hi,
this is the SQL statement I'm using:
SELECT TOP 100 PERCENT dbo.tblWoningen.*, dbo.Huren.*,
dbo.tblPuntenTotaal.*,
dbo.Woningen.Perceel AS Expr1
FROM dbo.Woningen LEFT OUTER JOIN
dbo.Huren ON
dbo.Woningen.Perceel = dbo.Huren.Perceelnr# LEFT
OUTER JOIN
dbo.tblPuntenTotaal ON dbo.Woningen.Perceel =dbo.tblPuntenTotaal.VHE_nummer
ORDER BY dbo.Woningen.Perceel
Franc.
>Can we see your code please.
>J
>
>>--Original Message--
>>I have screenshots available fot those interested. So far
>I've found 4
>>views which were affected. They were all based on the
>same tables. I
>>ran a dbcc checkdb and no error are reported on the
>database.
>>Franc.
>>Hi,
>>today I discovered a major and dangerous bug in SQL
>server. I've
>>created a view with many fields. When looking in the
>design manager
>>everything looks fine. However when I use the view, one
>of the column
>>headings is missing and the column names are shift to
>the left. The
>>values however are still on their own place. This
>results in a major
>>issue that the values appear under the wrong column. In
>design view
>>everything looks fine, but when you open the query it
>display the
>>wrong values. Thus:
>>In design view it looks like this:
>>Field1 Field2 Field3 Field4
>>1 2 3 4
>>When opening the query it looks like this:
>>Field1 Field3 Field4
>>1 2 3
>>How the hell is this possible. Changing one thing in the
>view saving
>>it again and then opneing it, everything is fine. But
>how do I know
>>which views are affected ?
>>Franc.
>>.|||Hi Greg,
no I haven't altered the tables below the views, only added data to
it. What I don't get is, why it looks correctly when run from design
view, but as soon as you run the view it goes wrong. After saving the
view from design view it displays the correct values again. Looks like
SQL is recompiling the view. Is there a way to force recompilation of
all view to ensure that everything is correct. Last week everything
worked fine, today we noticed that the wrong values appeared in field
on our mailing letters.
Franc.
On Thu, 13 May 2004 20:40:12 +1000, "Greg Linwood"
<g_linwoodQhotmail.com> wrote:
>Hi Franc
>Are you altering the objects underneath the view? This can cause the
>behaviour you're describing. That SQL Server lets you simply change objects
>underneath views without warning is not great, but this isn't a bug as such.
>You should look into using the SCHEMABINDING option in your CREATE VIEW
>statements. This was designed to ensure that the objects that views
>reference are not permitted to change underneath those views. That way, you
>don't have to trawl through lists of dependent objects to make sure
>everything is in synch..
>Regards,
>Greg Linwood
>SQL Server MVP
>"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
>news:40a34498.84859734@.msnews.microsoft.com...
>> Hi,
>> today I discovered a major and dangerous bug in SQL server. I've
>> created a view with many fields. When looking in the design manager
>> everything looks fine. However when I use the view, one of the column
>> headings is missing and the column names are shift to the left. The
>> values however are still on their own place. This results in a major
>> issue that the values appear under the wrong column. In design view
>> everything looks fine, but when you open the query it display the
>> wrong values. Thus:
>> In design view it looks like this:
>> Field1 Field2 Field3 Field4
>> 1 2 3 4
>> When opening the query it looks like this:
>> Field1 Field3 Field4
>> 1 2 3
>> How the hell is this possible. Changing one thing in the view saving
>> it again and then opneing it, everything is fine. But how do I know
>> which views are affected ?
>> Franc.
>|||Hi Franc
Using * in views is a bad idea. If the columns in the tables underneath the
view change, the view is not automatically updated. schemabinding would at
least help you by forcing the person who alters the columns in the
underlying tables to recompile the view.
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a35050.87859203@.msnews.microsoft.com...
> Hi,
> this is the SQL statement I'm using:
> SELECT TOP 100 PERCENT dbo.tblWoningen.*, dbo.Huren.*,
> dbo.tblPuntenTotaal.*,
> dbo.Woningen.Perceel AS Expr1
> FROM dbo.Woningen LEFT OUTER JOIN
> dbo.Huren ON
> dbo.Woningen.Perceel = dbo.Huren.Perceelnr# LEFT
> OUTER JOIN
> dbo.tblPuntenTotaal ON dbo.Woningen.Perceel => dbo.tblPuntenTotaal.VHE_nummer
> ORDER BY dbo.Woningen.Perceel
> Franc.
> >Can we see your code please.
> >
> >J
> >
> >
> >>--Original Message--
> >>I have screenshots available fot those interested. So far
> >I've found 4
> >>views which were affected. They were all based on the
> >same tables. I
> >>ran a dbcc checkdb and no error are reported on the
> >database.
> >>
> >>Franc.
> >>
> >>Hi,
> >>
> >>today I discovered a major and dangerous bug in SQL
> >server. I've
> >>created a view with many fields. When looking in the
> >design manager
> >>everything looks fine. However when I use the view, one
> >of the column
> >>headings is missing and the column names are shift to
> >the left. The
> >>values however are still on their own place. This
> >results in a major
> >>issue that the values appear under the wrong column. In
> >design view
> >>everything looks fine, but when you open the query it
> >display the
> >>wrong values. Thus:
> >>
> >>In design view it looks like this:
> >>
> >>Field1 Field2 Field3 Field4
> >>1 2 3 4
> >>
> >>When opening the query it looks like this:
> >>
> >>Field1 Field3 Field4
> >>1 2 3
> >>
> >>How the hell is this possible. Changing one thing in the
> >view saving
> >>it again and then opneing it, everything is fine. But
> >how do I know
> >>which views are affected ?
> >>
> >>Franc.
> >>
> >>.
> >>
>|||Hi Franc
Sorry for repeating a little in this thread, but this is what schemabinding
is for. It forces the person who's altering the table / view underneath the
view to recompile the view at the time the underlying object is altered.
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a35148.88107390@.msnews.microsoft.com...
> Hi Greg,
> no I haven't altered the tables below the views, only added data to
> it. What I don't get is, why it looks correctly when run from design
> view, but as soon as you run the view it goes wrong. After saving the
> view from design view it displays the correct values again. Looks like
> SQL is recompiling the view. Is there a way to force recompilation of
> all view to ensure that everything is correct. Last week everything
> worked fine, today we noticed that the wrong values appeared in field
> on our mailing letters.
> Franc.
> On Thu, 13 May 2004 20:40:12 +1000, "Greg Linwood"
> <g_linwoodQhotmail.com> wrote:
> >Hi Franc
> >
> >Are you altering the objects underneath the view? This can cause the
> >behaviour you're describing. That SQL Server lets you simply change
objects
> >underneath views without warning is not great, but this isn't a bug as
such.
> >
> >You should look into using the SCHEMABINDING option in your CREATE VIEW
> >statements. This was designed to ensure that the objects that views
> >reference are not permitted to change underneath those views. That way,
you
> >don't have to trawl through lists of dependent objects to make sure
> >everything is in synch..
> >
> >Regards,
> >Greg Linwood
> >SQL Server MVP
> >
> >"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
> >news:40a34498.84859734@.msnews.microsoft.com...
> >> Hi,
> >>
> >> today I discovered a major and dangerous bug in SQL server. I've
> >> created a view with many fields. When looking in the design manager
> >> everything looks fine. However when I use the view, one of the column
> >> headings is missing and the column names are shift to the left. The
> >> values however are still on their own place. This results in a major
> >> issue that the values appear under the wrong column. In design view
> >> everything looks fine, but when you open the query it display the
> >> wrong values. Thus:
> >>
> >> In design view it looks like this:
> >>
> >> Field1 Field2 Field3 Field4
> >> 1 2 3 4
> >>
> >> When opening the query it looks like this:
> >>
> >> Field1 Field3 Field4
> >> 1 2 3
> >>
> >> How the hell is this possible. Changing one thing in the view saving
> >> it again and then opneing it, everything is fine. But how do I know
> >> which views are affected ?
> >>
> >> Franc.
> >
> >
>|||If you post a complete repro script, we can try it on our SQL Servers and see if it reproduces...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a35050.87859203@.msnews.microsoft.com...
> Hi,
> this is the SQL statement I'm using:
> SELECT TOP 100 PERCENT dbo.tblWoningen.*, dbo.Huren.*,
> dbo.tblPuntenTotaal.*,
> dbo.Woningen.Perceel AS Expr1
> FROM dbo.Woningen LEFT OUTER JOIN
> dbo.Huren ON
> dbo.Woningen.Perceel = dbo.Huren.Perceelnr# LEFT
> OUTER JOIN
> dbo.tblPuntenTotaal ON dbo.Woningen.Perceel => dbo.tblPuntenTotaal.VHE_nummer
> ORDER BY dbo.Woningen.Perceel
> Franc.
> >Can we see your code please.
> >
> >J
> >
> >
> >>--Original Message--
> >>I have screenshots available fot those interested. So far
> >I've found 4
> >>views which were affected. They were all based on the
> >same tables. I
> >>ran a dbcc checkdb and no error are reported on the
> >database.
> >>
> >>Franc.
> >>
> >>Hi,
> >>
> >>today I discovered a major and dangerous bug in SQL
> >server. I've
> >>created a view with many fields. When looking in the
> >design manager
> >>everything looks fine. However when I use the view, one
> >of the column
> >>headings is missing and the column names are shift to
> >the left. The
> >>values however are still on their own place. This
> >results in a major
> >>issue that the values appear under the wrong column. In
> >design view
> >>everything looks fine, but when you open the query it
> >display the
> >>wrong values. Thus:
> >>
> >>In design view it looks like this:
> >>
> >>Field1 Field2 Field3 Field4
> >>1 2 3 4
> >>
> >>When opening the query it looks like this:
> >>
> >>Field1 Field3 Field4
> >>1 2 3
> >>
> >>How the hell is this possible. Changing one thing in the
> >view saving
> >>it again and then opneing it, everything is fine. But
> >how do I know
> >>which views are affected ?
> >>
> >>Franc.
> >>
> >>.
> >>
>|||Hi Greg,
ok, I'll alter the view by using schemabindings. However, I don't get
why SQL just moves the column names and not the data. If it would
remove the data also it's fine. Now you get the wrong data in the
wrong columns whcih is much more dangerous.
Franc.
>Hi Franc
>Sorry for repeating a little in this thread, but this is what schemabinding
>is for. It forces the person who's altering the table / view underneath the
>view to recompile the view at the time the underlying object is altered.
>Regards,
>Greg Linwood
>SQL Server MVP
>"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
>news:40a35148.88107390@.msnews.microsoft.com...
>> Hi Greg,
>> no I haven't altered the tables below the views, only added data to
>> it. What I don't get is, why it looks correctly when run from design
>> view, but as soon as you run the view it goes wrong. After saving the
>> view from design view it displays the correct values again. Looks like
>> SQL is recompiling the view. Is there a way to force recompilation of
>> all view to ensure that everything is correct. Last week everything
>> worked fine, today we noticed that the wrong values appeared in field
>> on our mailing letters.
>> Franc.
>> On Thu, 13 May 2004 20:40:12 +1000, "Greg Linwood"
>> <g_linwoodQhotmail.com> wrote:
>> >Hi Franc
>> >
>> >Are you altering the objects underneath the view? This can cause the
>> >behaviour you're describing. That SQL Server lets you simply change
>objects
>> >underneath views without warning is not great, but this isn't a bug as
>such.
>> >
>> >You should look into using the SCHEMABINDING option in your CREATE VIEW
>> >statements. This was designed to ensure that the objects that views
>> >reference are not permitted to change underneath those views. That way,
>you
>> >don't have to trawl through lists of dependent objects to make sure
>> >everything is in synch..
>> >
>> >Regards,
>> >Greg Linwood
>> >SQL Server MVP
>> >
>> >"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
>> >news:40a34498.84859734@.msnews.microsoft.com...
>> >> Hi,
>> >>
>> >> today I discovered a major and dangerous bug in SQL server. I've
>> >> created a view with many fields. When looking in the design manager
>> >> everything looks fine. However when I use the view, one of the column
>> >> headings is missing and the column names are shift to the left. The
>> >> values however are still on their own place. This results in a major
>> >> issue that the values appear under the wrong column. In design view
>> >> everything looks fine, but when you open the query it display the
>> >> wrong values. Thus:
>> >>
>> >> In design view it looks like this:
>> >>
>> >> Field1 Field2 Field3 Field4
>> >> 1 2 3 4
>> >>
>> >> When opening the query it looks like this:
>> >>
>> >> Field1 Field3 Field4
>> >> 1 2 3
>> >>
>> >> How the hell is this possible. Changing one thing in the view saving
>> >> it again and then opneing it, everything is fine. But how do I know
>> >> which views are affected ?
>> >>
>> >> Franc.
>> >
>> >
>|||I'm not sure & couldn't answer that precisely with the info at hand. Maybe
someone else might chip in with an explanation on that bit. Hopefully it's
clear for you now what schemabinding's about & why it's important to the
stability of views though.
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a36040.91940250@.msnews.microsoft.com...
> Hi Greg,
> ok, I'll alter the view by using schemabindings. However, I don't get
> why SQL just moves the column names and not the data. If it would
> remove the data also it's fine. Now you get the wrong data in the
> wrong columns whcih is much more dangerous.
> Franc.
> >Hi Franc
> >
> >Sorry for repeating a little in this thread, but this is what
schemabinding
> >is for. It forces the person who's altering the table / view underneath
the
> >view to recompile the view at the time the underlying object is altered.
> >
> >Regards,
> >Greg Linwood
> >SQL Server MVP
> >
> >"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
> >news:40a35148.88107390@.msnews.microsoft.com...
> >> Hi Greg,
> >>
> >> no I haven't altered the tables below the views, only added data to
> >> it. What I don't get is, why it looks correctly when run from design
> >> view, but as soon as you run the view it goes wrong. After saving the
> >> view from design view it displays the correct values again. Looks like
> >> SQL is recompiling the view. Is there a way to force recompilation of
> >> all view to ensure that everything is correct. Last week everything
> >> worked fine, today we noticed that the wrong values appeared in field
> >> on our mailing letters.
> >>
> >> Franc.
> >>
> >> On Thu, 13 May 2004 20:40:12 +1000, "Greg Linwood"
> >> <g_linwoodQhotmail.com> wrote:
> >>
> >> >Hi Franc
> >> >
> >> >Are you altering the objects underneath the view? This can cause the
> >> >behaviour you're describing. That SQL Server lets you simply change
> >objects
> >> >underneath views without warning is not great, but this isn't a bug as
> >such.
> >> >
> >> >You should look into using the SCHEMABINDING option in your CREATE
VIEW
> >> >statements. This was designed to ensure that the objects that views
> >> >reference are not permitted to change underneath those views. That
way,
> >you
> >> >don't have to trawl through lists of dependent objects to make sure
> >> >everything is in synch..
> >> >
> >> >Regards,
> >> >Greg Linwood
> >> >SQL Server MVP
> >> >
> >> >"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
> >> >news:40a34498.84859734@.msnews.microsoft.com...
> >> >> Hi,
> >> >>
> >> >> today I discovered a major and dangerous bug in SQL server. I've
> >> >> created a view with many fields. When looking in the design manager
> >> >> everything looks fine. However when I use the view, one of the
column
> >> >> headings is missing and the column names are shift to the left. The
> >> >> values however are still on their own place. This results in a major
> >> >> issue that the values appear under the wrong column. In design view
> >> >> everything looks fine, but when you open the query it display the
> >> >> wrong values. Thus:
> >> >>
> >> >> In design view it looks like this:
> >> >>
> >> >> Field1 Field2 Field3 Field4
> >> >> 1 2 3 4
> >> >>
> >> >> When opening the query it looks like this:
> >> >>
> >> >> Field1 Field3 Field4
> >> >> 1 2 3
> >> >>
> >> >> How the hell is this possible. Changing one thing in the view saving
> >> >> it again and then opneing it, everything is fine. But how do I know
> >> >> which views are affected ?
> >> >>
> >> >> Franc.
> >> >
> >> >
> >>
> >
> >
>|||SQL Server is not moving anything. It is the client application that is
just not displaying it properly.
Rand
This posting is provided "as is" with no warranties and confers no rights.|||Hi,
no that's not the case. I can prove it to you with some screen shots.
Those clearly show that when run from the design manger it looks fine
but as soon as I use query analyzer the wrong data is displayed. And
the wrong data is also presented to our intranet application which
uses the view and a word mailing document which also uses the view.
It's definitely something wrong with SQL server. I'm not using a
client application to fill or manipulate the data.
Franc.
>SQL Server is not moving anything. It is the client application that is
>just not displaying it properly.
>Rand
>This posting is provided "as is" with no warranties and confers no rights.|||Hi Franc,
Would it be possible to send me screen shots in .jpeg
format.
My email is little_flowery_me@.hotmail.com
J
>--Original Message--
>Hi,
>no that's not the case. I can prove it to you with some
screen shots.
>Those clearly show that when run from the design manger
it looks fine
>but as soon as I use query analyzer the wrong data is
displayed. And
>the wrong data is also presented to our intranet
application which
>uses the view and a word mailing document which also
uses the view.
> It's definitely something wrong with SQL server. I'm
not using a
>client application to fill or manipulate the data.
>Franc.
>>SQL Server is not moving anything. It is the client
application that is
>>just not displaying it properly.
>>Rand
>>This posting is provided "as is" with no warranties and
confers no rights.
>.
>
major bug in SQL 2000
today I discovered a major and dangerous bug in SQL server. I've
created a view with many fields. When looking in the design manager
everything looks fine. However when I use the view, one of the column
headings is missing and the column names are shift to the left. The
values however are still on their own place. This results in a major
issue that the values appear under the wrong column. In design view
everything looks fine, but when you open the query it display the
wrong values. Thus:
In design view it looks like this:
Field1Field2Field3Field4
1234
When opening the query it looks like this:
Field1Field3Field4
123
How the hell is this possible. Changing one thing in the view saving
it again and then opneing it, everything is fine. But how do I know
which views are affected ?
Franc.
I have screenshots available fot those interested. So far I've found 4
views which were affected. They were all based on the same tables. I
ran a dbcc checkdb and no error are reported on the database.
Franc.
>Hi,
>today I discovered a major and dangerous bug in SQL server. I've
>created a view with many fields. When looking in the design manager
>everything looks fine. However when I use the view, one of the column
>headings is missing and the column names are shift to the left. The
>values however are still on their own place. This results in a major
>issue that the values appear under the wrong column. In design view
>everything looks fine, but when you open the query it display the
>wrong values. Thus:
>In design view it looks like this:
>Field1Field2Field3Field4
>1234
>When opening the query it looks like this:
>Field1Field3Field4
>123
>How the hell is this possible. Changing one thing in the view saving
>it again and then opneing it, everything is fine. But how do I know
>which views are affected ?
>Franc.
|||Can we see your code please.
J
>--Original Message--
>I have screenshots available fot those interested. So far
I've found 4
>views which were affected. They were all based on the
same tables. I
>ran a dbcc checkdb and no error are reported on the
database.[vbcol=seagreen]
>Franc.
server. I've[vbcol=seagreen]
design manager[vbcol=seagreen]
of the column[vbcol=seagreen]
the left. The[vbcol=seagreen]
results in a major[vbcol=seagreen]
design view[vbcol=seagreen]
display the[vbcol=seagreen]
view saving[vbcol=seagreen]
how do I know
>.
>
|||Hi Franc
Are you altering the objects underneath the view? This can cause the
behaviour you're describing. That SQL Server lets you simply change objects
underneath views without warning is not great, but this isn't a bug as such.
You should look into using the SCHEMABINDING option in your CREATE VIEW
statements. This was designed to ensure that the objects that views
reference are not permitted to change underneath those views. That way, you
don't have to trawl through lists of dependent objects to make sure
everything is in synch..
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a34498.84859734@.msnews.microsoft.com...
> Hi,
> today I discovered a major and dangerous bug in SQL server. I've
> created a view with many fields. When looking in the design manager
> everything looks fine. However when I use the view, one of the column
> headings is missing and the column names are shift to the left. The
> values however are still on their own place. This results in a major
> issue that the values appear under the wrong column. In design view
> everything looks fine, but when you open the query it display the
> wrong values. Thus:
> In design view it looks like this:
> Field1 Field2 Field3 Field4
> 1 2 3 4
> When opening the query it looks like this:
> Field1 Field3 Field4
> 1 2 3
> How the hell is this possible. Changing one thing in the view saving
> it again and then opneing it, everything is fine. But how do I know
> which views are affected ?
> Franc.
|||Hi,
this is the SQL statement I'm using:
SELECT TOP 100 PERCENT dbo.tblWoningen.*, dbo.Huren.*,
dbo.tblPuntenTotaal.*,
dbo.Woningen.Perceel AS Expr1
FROM dbo.Woningen LEFT OUTER JOIN
dbo.Huren ON
dbo.Woningen.Perceel = dbo.Huren.Perceelnr# LEFT
OUTER JOIN
dbo.tblPuntenTotaal ON dbo.Woningen.Perceel =
dbo.tblPuntenTotaal.VHE_nummer
ORDER BY dbo.Woningen.Perceel
Franc.
[vbcol=seagreen]
>Can we see your code please.
>J
>
>I've found 4
>same tables. I
>database.
>server. I've
>design manager
>of the column
>the left. The
>results in a major
>design view
>display the
>view saving
>how do I know
|||Hi Greg,
no I haven't altered the tables below the views, only added data to
it. What I don't get is, why it looks correctly when run from design
view, but as soon as you run the view it goes wrong. After saving the
view from design view it displays the correct values again. Looks like
SQL is recompiling the view. Is there a way to force recompilation of
all view to ensure that everything is correct. Last week everything
worked fine, today we noticed that the wrong values appeared in field
on our mailing letters.
Franc.
On Thu, 13 May 2004 20:40:12 +1000, "Greg Linwood"
<g_linwoodQhotmail.com> wrote:
>Hi Franc
>Are you altering the objects underneath the view? This can cause the
>behaviour you're describing. That SQL Server lets you simply change objects
>underneath views without warning is not great, but this isn't a bug as such.
>You should look into using the SCHEMABINDING option in your CREATE VIEW
>statements. This was designed to ensure that the objects that views
>reference are not permitted to change underneath those views. That way, you
>don't have to trawl through lists of dependent objects to make sure
>everything is in synch..
>Regards,
>Greg Linwood
>SQL Server MVP
>"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
>news:40a34498.84859734@.msnews.microsoft.com...
>
|||Hi Franc
Using * in views is a bad idea. If the columns in the tables underneath the
view change, the view is not automatically updated. schemabinding would at
least help you by forcing the person who alters the columns in the
underlying tables to recompile the view.
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a35050.87859203@.msnews.microsoft.com...
> Hi,
> this is the SQL statement I'm using:
> SELECT TOP 100 PERCENT dbo.tblWoningen.*, dbo.Huren.*,
> dbo.tblPuntenTotaal.*,
> dbo.Woningen.Perceel AS Expr1
> FROM dbo.Woningen LEFT OUTER JOIN
> dbo.Huren ON
> dbo.Woningen.Perceel = dbo.Huren.Perceelnr# LEFT
> OUTER JOIN
> dbo.tblPuntenTotaal ON dbo.Woningen.Perceel =
> dbo.tblPuntenTotaal.VHE_nummer
> ORDER BY dbo.Woningen.Perceel
> Franc.
>
|||Hi Franc
Sorry for repeating a little in this thread, but this is what schemabinding
is for. It forces the person who's altering the table / view underneath the
view to recompile the view at the time the underlying object is altered.
Regards,
Greg Linwood
SQL Server MVP
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a35148.88107390@.msnews.microsoft.com...[vbcol=seagreen]
> Hi Greg,
> no I haven't altered the tables below the views, only added data to
> it. What I don't get is, why it looks correctly when run from design
> view, but as soon as you run the view it goes wrong. After saving the
> view from design view it displays the correct values again. Looks like
> SQL is recompiling the view. Is there a way to force recompilation of
> all view to ensure that everything is correct. Last week everything
> worked fine, today we noticed that the wrong values appeared in field
> on our mailing letters.
> Franc.
> On Thu, 13 May 2004 20:40:12 +1000, "Greg Linwood"
> <g_linwoodQhotmail.com> wrote:
objects[vbcol=seagreen]
such.[vbcol=seagreen]
you
>
|||If you post a complete repro script, we can try it on our SQL Servers and see if it reproduces...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
news:40a35050.87859203@.msnews.microsoft.com...
> Hi,
> this is the SQL statement I'm using:
> SELECT TOP 100 PERCENT dbo.tblWoningen.*, dbo.Huren.*,
> dbo.tblPuntenTotaal.*,
> dbo.Woningen.Perceel AS Expr1
> FROM dbo.Woningen LEFT OUTER JOIN
> dbo.Huren ON
> dbo.Woningen.Perceel = dbo.Huren.Perceelnr# LEFT
> OUTER JOIN
> dbo.tblPuntenTotaal ON dbo.Woningen.Perceel =
> dbo.tblPuntenTotaal.VHE_nummer
> ORDER BY dbo.Woningen.Perceel
> Franc.
>
|||Hi Greg,
ok, I'll alter the view by using schemabindings. However, I don't get
why SQL just moves the column names and not the data. If it would
remove the data also it's fine. Now you get the wrong data in the
wrong columns whcih is much more dangerous.
Franc.
>Hi Franc
>Sorry for repeating a little in this thread, but this is what schemabinding
>is for. It forces the person who's altering the table / view underneath the
>view to recompile the view at the time the underlying object is altered.
>Regards,
>Greg Linwood
>SQL Server MVP
>"Franc v/d Westelaken" <fvdwestelaken@.hotmail.com> wrote in message
>news:40a35148.88107390@.msnews.microsoft.com...
>objects
>such.
>you
>
Wednesday, March 7, 2012
Maintenance-Backup question
I have a SQl database, when I view its properties from Enterprise manager, it's size is about 159 MB. I'm pretty sure I don't have that mucj data in it.
I know that Transaction log files grow over time, but I don't know how to control its growth? Is there a way to delete logs that are unecessary?
By backing up Transaction logs in a maintenance plan will the problem be solved?if you don't need transaction logs change your recovery model to Simple, that way the transaction logs will be truncated at checkpoint.
If you need transaction logs then you should be backing them up on a regular basis. After backup you can truncate the logs. See BOL and maintenance plan for syntax.|||Thanks for your reply,
I have read BOL's explanation of backups and recovery models, however I'm still confused.
I need to be able to have point in time recovery, therefor I've set the backup mode to FULL.
I have a maintenance plan that backs up both Log files and the database on a daily bases.
My confusion is mainly on the issue of Full versus other types of recovery models.
I want to have point in time recovery therefore I need the FULL Recovery mode, but at the same time I am able to determine at a specific point in time if I'm sure I don't need the transaction logs before that specific date and the previous daily backups won't be usfull, therefore I have came up with the below solution which I'm not sure if its correct:
"I will use the Daily log and data backup with the FULL Recovery mode. Then at any given time when I determine I won't need the Log files, I will temporary change the Rocovery mode to "SIMPLE" and manually backup the Log and data files, then after the manual back I will change the Recovery mode to FULL so that the daily scheduled backups will be in the FULL mode. This Way I get rid of the useless transaction logs and keep the new logs untill the next manual backup when I know that I'm safe."
Is this strategy correct?
Thanks|||Ah no.
Set your recovery model to full and DON'T change it unless you are doing big time data/server maintance.
My suggestion is to create a schedule of full backups and transaction log backups.
All transaction logs can be deleted AFTER a full backup is again taken.
Lets say to make a full backup each night at 01:30. Your system doesn't see much activity untill 07:00, is failry heavily used till 19:00 and little activity till 01:30 the next morning. I would take a log dump at 07:00, 19:00 and maybe 20:00. Between 07:00 and 19:00 you might want to take a log dump every hour of half hour. Regardless of the number of log dumps taken you can get rid of them after the next sucessful full backup.
You can specify al this in the maintance plan.
Think about this and poste back.|||Also, lookup "differential backups" in BOL, another good example of a backup strategy.|||A log dump is what I wanted to do, how do I specify a log dump?
Is a log dump another term for backing up transactions logs?
Originally posted by Paul Young
Ah no.
Set your recovery model to full and DON'T change it unless you are doing big time data/server maintance.
My suggestion is to create a schedule of full backups and transaction log backups.
All transaction logs can be deleted AFTER a full backup is again taken.
Lets say to make a full backup each night at 01:30. Your system doesn't see much activity untill 07:00, is failry heavily used till 19:00 and little activity till 01:30 the next morning. I would take a log dump at 07:00, 19:00 and maybe 20:00. Between 07:00 and 19:00 you might want to take a log dump every hour of half hour. Regardless of the number of log dumps taken you can get rid of them after the next sucessful full backup.
You can specify al this in the maintance plan.
Think about this and poste back.|||After backing up, use dbcc shrink file to shrink log file. Since DBCC shrinkfile only shrink from the end of the log file, sometime you have to intentionally do some operations to move the log to the start of the log file. Normally, after two times of backup and dbcc shrink, the log file will be shrinked dramatiscally.
Search google for Andrew Zanevsky, he wrote a good article and script of how to autamatically do the above steps.
Here's header of this script.
use master
go
if object_id( 'sp_force_shrink_log' ) is not null drop proc sp_force_shrink_log
go
create proc sp_force_shrink_log
/*
************************************************** ***********
Name: sp_force_shrink_log
Description:
Shrink transaction log of the current database in SQL Server 7.0.
Switch context to proper db to execute.
Usage: exec sp_force_shrink_log <target_percent>, <target MB>, <iterations>, <backup options>
exec pubs..sp_force_shrink_log
Author: Andrew Zanevsky, AZ Databases, Inc., 12/25/1999, v5 - 08/18/2000
zanevsky@.azdatabases.com|||Originally posted by Sia
A log dump is what I wanted to do, how do I specify a log dump?
Is a log dump another term for backing up transactions logs?
Yes, refer to BOL for Tlog backups.|||Sia, finally found the article in BOL... look up "transaction logs, truncating" This should help you out.
Yes, log dump = backing up transaction log.
You will need to follow jzhu suggestion on shrinking the log files if yo uhave auto shrink turned off. IMNotSoHO I would wathc the log files and only shrink is space were a problem. If you consistantly need 1 gig of log space why go through the cycle of shrinking and growing? I shrink my logs only once a month.|||Thanks for your replay Paul.
I think I got it!|||Paul,
Thanks for your recent replys.
I have scheduled a Database and Log backup every day at 1 and 2 am.
The thing is that, before I do the Log backup my database had the following properties:
Space alloacted for data file was 50MB
Space alloacted for Log file was about 100 MB
availble space was about 70MB.
The I did a manual database and Log backup which resulted in the following db properties
Space alloacted for data file =50MB
Space alloacted for Log file =50MB
availble space= 100MB
Its now about 2 days that I'm doing the Log and Data backup using a scheduled maintenance plan.
I have the following DB Properties:
Space alloacted for data file =50MB
Space alloacted for Log file =2 MB
availble space= 14MB
=>My questions:
Why did the Log File size reduced dramatically after 2 backups with the maintenance plan but was not reduced that much when I did the first 2 backups manually.
Why is the "availble space" reduced!
My guess is that the availble space is calculated using the allocated space and since I have autogrowth it woud increase itself when the file reaches the limit.
I would appreciate if you let me know I'm on the right track or not.
Thanks
Originally posted by Sia
Thanks for your reply,
I have read BOL's explanation of backups and recovery models, however I'm still confused.
I need to be able to have point in time recovery, therefor I've set the backup mode to FULL.
I have a maintenance plan that backs up both Log files and the database on a daily bases.
My confusion is mainly on the issue of Full versus other types of recovery models.
I want to have point in time recovery therefore I need the FULL Recovery mode, but at the same time I am able to determine at a specific point in time if I'm sure I don't need the transaction logs before that specific date and the previous daily backups won't be usfull, therefore I have came up with the below solution which I'm not sure if its correct:
"I will use the Daily log and data backup with the FULL Recovery mode. Then at any given time when I determine I won't need the Log files, I will temporary change the Rocovery mode to "SIMPLE" and manually backup the Log and data files, then after the manual back I will change the Recovery mode to FULL so that the daily scheduled backups will be in the FULL mode. This Way I get rid of the useless transaction logs and keep the new logs untill the next manual backup when I know that I'm safe."
Is this strategy correct?
Thanks|||Okay, just because you truncated the log does not mean you will automatically reduce the size of the log file. When you dup the log file you are backing up all COMMITED transactions and then removing all the transactions you just backed up. There may have been several long running un-commited transactions still in the log. These transaction many cover several segmants in the log file and there for the log file can not be shrunk. It's kind of like a fragmented hard drive.
As for your 2nd question, your are on the right track. I have read all about this one in BOL but it gave me a head ache. Available space depens on the total size of db and log space and how much of each is used.
Bottom line is if you see your new maintance plan is working for you try it out for a month, you will probably need to make a few adjustments but you won't know till you let it run for a while|||Thank you for your help!
Originally posted by Paul Young
Okay, just because you truncated the log does not mean you will automatically reduce the size of the log file. When you dup the log file you are backing up all COMMITED transactions and then removing all the transactions you just backed up. There may have been several long running un-commited transactions still in the log. These transaction many cover several segmants in the log file and there for the log file can not be shrunk. It's kind of like a fragmented hard drive.
As for your 2nd question, your are on the right track. I have read all about this one in BOL but it gave me a head ache. Available space depens on the total size of db and log space and how much of each is used.
Bottom line is if you see your new maintance plan is working for you try it out for a month, you will probably need to make a few adjustments but you won't know till you let it run for a while
Maintenance Plans Have "Disappeared"
My maintenance plans have disapeared from View, although
according to the Databases that use the Plans they still
exist..
To test this I created a quick Maintenance Plan and sure
enough it created but it cannot be seen!!
Does anybody have any ideas or should I call the
Ghostbusters?
I am using SQL Server V7.0, using Enterpise Manager on my
PC to Administer the Server.
TIA
Tony C.
Tony,
Maybe the tasks have been created under say the SA account, but you're
connected and browsing the server under a different account that does not
have permissions to view those tasks.?
Immy
"Tony C" <anonymous@.discussions.microsoft.com> wrote in message
news:1a0ff01c41d7c$0f74f590$a401280a@.phx.gbl...
> Help!!
> My maintenance plans have disapeared from View, although
> according to the Databases that use the Plans they still
> exist..
> To test this I created a quick Maintenance Plan and sure
> enough it created but it cannot be seen!!
> Does anybody have any ideas or should I call the
> Ghostbusters?
> I am using SQL Server V7.0, using Enterpise Manager on my
> PC to Administer the Server.
> TIA
>
> Tony C.