Showing posts with label exist. Show all posts
Showing posts with label exist. Show all posts

Tuesday, March 27, 2012

Change in Statistics

I added several indexes and statistics to a SQL 2000
database, and the next day I found that 4 of the
statistics no longer exist. Is there any way that the
auto create/update statistics could have caused this? Or
anything else, other than dropping them?
In addition, what effect would this have on my query
performance? I'm a little unsure about how the indexes
and statistics work together, but any help would be
greatly appreciated.
Thank you,
HeidiI guess somebody or some job deleted that statistics. SQL dose not delete
index or statistics by itself.
Since, SQL server dose cost based optimization, the statistics is very
important to decide the good plan. it must be up to date.
"hdsjunk" <anonymous@.discussions.microsoft.com> wrote in message
news:103d01c48bc9$682e5210$a301280a@.phx.gbl...
> I added several indexes and statistics to a SQL 2000
> database, and the next day I found that 4 of the
> statistics no longer exist. Is there any way that the
> auto create/update statistics could have caused this? Or
> anything else, other than dropping them?
> In addition, what effect would this have on my query
> performance? I'm a little unsure about how the indexes
> and statistics work together, but any help would be
> greatly appreciated.
> Thank you,
> Heidi|||Heidi,
It is likely that a job or other process, or even a person deleted these
statistics. SQL Server won't delete statistics without being asked.
If you do not have statistics on larger tables, SQL Server finds it
difficult to know what indexes to choose when compiling the query plan.
It will quite often choose the wrong index if you do not have
statistics, or if your statistics are wildly inaccurate (out-of-date).
--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
hdsjunk wrote:
> I added several indexes and statistics to a SQL 2000
> database, and the next day I found that 4 of the
> statistics no longer exist. Is there any way that the
> auto create/update statistics could have caused this? Or
> anything else, other than dropping them?
> In addition, what effect would this have on my query
> performance? I'm a little unsure about how the indexes
> and statistics work together, but any help would be
> greatly appreciated.
> Thank you,
> Heidi

Change in Statistics

I added several indexes and statistics to a SQL 2000
database, and the next day I found that 4 of the
statistics no longer exist. Is there any way that the
auto create/update statistics could have caused this? Or
anything else, other than dropping them?
In addition, what effect would this have on my query
performance? I'm a little unsure about how the indexes
and statistics work together, but any help would be
greatly appreciated.
Thank you,
Heidi
I guess somebody or some job deleted that statistics. SQL dose not delete
index or statistics by itself.
Since, SQL server dose cost based optimization, the statistics is very
important to decide the good plan. it must be up to date.
"hdsjunk" <anonymous@.discussions.microsoft.com> wrote in message
news:103d01c48bc9$682e5210$a301280a@.phx.gbl...
> I added several indexes and statistics to a SQL 2000
> database, and the next day I found that 4 of the
> statistics no longer exist. Is there any way that the
> auto create/update statistics could have caused this? Or
> anything else, other than dropping them?
> In addition, what effect would this have on my query
> performance? I'm a little unsure about how the indexes
> and statistics work together, but any help would be
> greatly appreciated.
> Thank you,
> Heidi
|||Heidi,
It is likely that a job or other process, or even a person deleted these
statistics. SQL Server won't delete statistics without being asked.
If you do not have statistics on larger tables, SQL Server finds it
difficult to know what indexes to choose when compiling the query plan.
It will quite often choose the wrong index if you do not have
statistics, or if your statistics are wildly inaccurate (out-of-date).
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
hdsjunk wrote:
> I added several indexes and statistics to a SQL 2000
> database, and the next day I found that 4 of the
> statistics no longer exist. Is there any way that the
> auto create/update statistics could have caused this? Or
> anything else, other than dropping them?
> In addition, what effect would this have on my query
> performance? I'm a little unsure about how the indexes
> and statistics work together, but any help would be
> greatly appreciated.
> Thank you,
> Heidi
sql

Change in Statistics

I added several indexes and statistics to a SQL 2000
database, and the next day I found that 4 of the
statistics no longer exist. Is there any way that the
auto create/update statistics could have caused this? Or
anything else, other than dropping them?
In addition, what effect would this have on my query
performance? I'm a little unsure about how the indexes
and statistics work together, but any help would be
greatly appreciated.
Thank you,
HeidiI guess somebody or some job deleted that statistics. SQL dose not delete
index or statistics by itself.
Since, SQL server dose cost based optimization, the statistics is very
important to decide the good plan. it must be up to date.
"hdsjunk" <anonymous@.discussions.microsoft.com> wrote in message
news:103d01c48bc9$682e5210$a301280a@.phx.gbl...
> I added several indexes and statistics to a SQL 2000
> database, and the next day I found that 4 of the
> statistics no longer exist. Is there any way that the
> auto create/update statistics could have caused this? Or
> anything else, other than dropping them?
> In addition, what effect would this have on my query
> performance? I'm a little unsure about how the indexes
> and statistics work together, but any help would be
> greatly appreciated.
> Thank you,
> Heidi|||Heidi,
It is likely that a job or other process, or even a person deleted these
statistics. SQL Server won't delete statistics without being asked.
If you do not have statistics on larger tables, SQL Server finds it
difficult to know what indexes to choose when compiling the query plan.
It will quite often choose the wrong index if you do not have
statistics, or if your statistics are wildly inaccurate (out-of-date).
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
hdsjunk wrote:
> I added several indexes and statistics to a SQL 2000
> database, and the next day I found that 4 of the
> statistics no longer exist. Is there any way that the
> auto create/update statistics could have caused this? Or
> anything else, other than dropping them?
> In addition, what effect would this have on my query
> performance? I'm a little unsure about how the indexes
> and statistics work together, but any help would be
> greatly appreciated.
> Thank you,
> Heidi

Saturday, February 25, 2012

CFE2SQL Server does not exist or access denied.

Does anyone have any idea what is causing the following error.
"CFE2SQL Server does not exist or access denied."
--
Thanks
JDSJDS wrote:
> Does anyone have any idea what is causing the following error.
> "CFE2SQL Server does not exist or access denied."
>
I'd say the server does not exist, can't be accessed, or you don't have
permission to use it. Without further detail, that's about all I can offer.|||The Server exist and this problem is happen sporadically. I can't find any
information on what is CFE2SQL.
--
Thanks
JDS
"Tracy McKibben" wrote:
> JDS wrote:
> > Does anyone have any idea what is causing the following error.
> >
> > "CFE2SQL Server does not exist or access denied."
> >
> >
> I'd say the server does not exist, can't be accessed, or you don't have
> permission to use it. Without further detail, that's about all I can offer.
>|||JDS wrote:
> The Server exist and this problem is happen sporadically. I can't find any
> information on what is CFE2SQL.
Where are you seeing this message displayed? The actual error message
is "SQL Server does not exist or access denied", the "CFE2" part is
coming from elsewhere.

CFE2SQL Server does not exist or access denied.

JDS wrote:
> Does anyone have any idea what is causing the following error.
> "CFE2SQL Server does not exist or access denied."
>
I'd say the server does not exist, can't be accessed, or you don't have
permission to use it. Without further detail, that's about all I can offer.The Server exist and this problem is happen sporadically. I can't find any
information on what is CFE2SQL.
--
Thanks
JDS
"Tracy McKibben" wrote:

> JDS wrote:
> I'd say the server does not exist, can't be accessed, or you don't have
> permission to use it. Without further detail, that's about all I can offe
r.
>|||Does anyone have any idea what is causing the following error.
"CFE2SQL Server does not exist or access denied."
Thanks
JDS|||JDS wrote:
> Does anyone have any idea what is causing the following error.
> "CFE2SQL Server does not exist or access denied."
>
I'd say the server does not exist, can't be accessed, or you don't have
permission to use it. Without further detail, that's about all I can offer.|||The Server exist and this problem is happen sporadically. I can't find any
information on what is CFE2SQL.
--
Thanks
JDS
"Tracy McKibben" wrote:

> JDS wrote:
> I'd say the server does not exist, can't be accessed, or you don't have
> permission to use it. Without further detail, that's about all I can offe
r.
>|||JDS wrote:
> The Server exist and this problem is happen sporadically. I can't find any
> information on what is CFE2SQL.
Where are you seeing this message displayed? The actual error message
is "SQL Server does not exist or access denied", the "CFE2" part is
coming from elsewhere.|||JDS wrote:
> The Server exist and this problem is happen sporadically. I can't find any
> information on what is CFE2SQL.
Where are you seeing this message displayed? The actual error message
is "SQL Server does not exist or access denied", the "CFE2" part is
coming from elsewhere.

Tuesday, February 14, 2012

catch sql command if value doesnt exist

I have a sql command that is loaded on page load that collects information based on the query string. The query string is a random group of numbers and letters. How do I catch it and direct to an error page if the query can not be found in the database?

Thanks!

if you are trying to get some parameters from the querystring then you can use

dim queryvariable as string =request.querystring("variable")

try

dim sqlquery as string

sqlquery="SELECT column_Name from Table_name where variable= "& queryvariable

//use this sqlquery to check whether it returns some rows or not

catch

response.redirect("pageNotFound.aspx")

end try

|||

I'm pretty sure i did all that.

in page load i'm doing

getUserInfo(Request.QueryString["uid"]);

then the method

protected void getUserInfo(string userid) {string selectCmd ="SELECT * from users WHERE ID = @.id";string strConnection = ConfigurationManager.ConnectionStrings["TimeAccountingConnectionString"].ConnectionString; SqlConnection myConnection =new SqlConnection(strConnection); SqlCommand myCommand =new SqlCommand(selectCmd, myConnection); myCommand.Parameters.Add(new SqlParameter("@.id", SqlDbType.VarChar, 10)); myCommand.Parameters["@.id"].Value = userid;try { myConnection.Open(); SqlDataReader datareader = myCommand.ExecuteReader();while (datareader.Read()) { lblFirstName.Text = datareader["firstname"].ToString(); lblLastName.Text = datareader["lastname"].ToString(); lblTeam.Text = datareader["team"].ToString(); lblOffice.Text = datareader["office"].ToString(); } datareader.Close(); myConnection.Close(); }catch { Response.Redirect("~/error.aspx"); }
|||

any ideas?

|||

In your code you aren't checking if the datareader actually contains any data or not, so if no records are being returned nothing happens. 1 simple way to do it is:

1. Declare a boolean variable at the top initialized to False: boolean bolUserFound = False

2. Inside the while loop set the value to true: bolUserFound = True

3. After you close the connection evaluate the variable and if it's still false you know no records were found and you need to redirect to your error page:

if (bolUserFound = False) {

Response.Redirect("~/error.aspx");

}

|||

perfect!

Exactly what i needed...