After creating an index on a rather small table (approx. 700 rows, 10 colums) I started to get
System.Data.SqlClient.SqlException: Timeout expired
The index was clusterd on the primary key.
There are no triggers.
All of these errors occured when doing an update via a stored procedure.
After I removed the index I had no more time-out issues.
Setting CommandTimeout did not help.
Does anybody has an idea why this was happening?
stored procedure (nothing special here)
Update objects set date_last_datacollect=#date_last_datacollect,
date_last_error='',message_last_error='' where objectid = #objectid
Table structure
CREATE TABLE [dbo].[objects](
[id] [int] IDENTITY(1,1) NOT NULL,
[objectid] [nvarchar](50) NULL,
[name] [nvarchar](max) NULL,
[adminid] [nvarchar](50) NULL,
[token] [nvarchar](max) NULL,
[type] [nvarchar](max) NULL,
[date_added] [date] NULL,
[date_last_update] [datetime] NULL,
[date_last_datacollect] [datetime] NULL,
[date_last_error] [datetime] NULL,
[message_last_error] [nvarchar](max) NULL,
[active] [bit] NULL,
[logourl] [nchar](255) NULL
) ON [PRIMARY]
edit:
After viewing my table structure I realize it might be due to the missing primary key?
Have you tried updating statistics on the table?
Related
I'm using fullCalendar jQuery plugin in which users can add events to a database table..
This is my events table
CREATE TABLE [dbo].[Events]
(
[EventID] [int] IDENTITY(1,1) NOT NULL,
[Subject] [nvarchar](100) NULL,
[Description] [nvarchar](300) NULL,
[Start] [datetime] NOT NULL,
[EndT] [datetime] NULL,
[ThemeColor] [nvarchar](10) NULL,
[IsFullDay] [bit] NULL,
[userID] [int] NOT NULL,
PRIMARY KEY [EventID]
)
ALTER TABLE [dbo].[Events] WITH CHECK
ADD CONSTRAINT [FK_Events_Users]
FOREIGN KEY([userID]) REFERENCES [dbo].[Users] ([userID])
It works well and the getEvents function successes .. But, When I tried to associate the events table with another table in the database (add a foreign key that reference another table like the users table)
[userID] [int] NOT NULL,
the fullCalendar fails to load .. I can not even see the calendar on the page
If I remove the relationship it works..
How can I make it work without removing the relationship as I need to know the events belongs to which user..??
Thanks
I'm using SQL Server ..
I want to display Data after Secure Login. Using Label and textboxes. And also want to use session variable to expire login.
My problem is that. how to display this data in user Home page.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblEmployeeDetail](
[EmployeeID] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [nvarchar](25) NOT NULL,
[LastName] [nvarchar](25) NOT NULL,
[UserName] [nvarchar](50) NOT NULL,
[Gender] [nvarchar](20) NOT NULL,
[Password] [nvarchar](50) NOT NULL,
[Email] [nvarchar](50) NOT NULL,
[Telephone] [bigint] NOT NULL,
[HouseNo] [nvarchar](25) NOT NULL,
[Street] [nvarchar](25) NOT NULL,
[Locality] [nvarchar](25) NOT NULL,
[City] [nvarchar](50) NOT NULL,
[State] [nvarchar](50) NOT NULL,
[Pincode] [int] NOT NULL,
[Country] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_tblEmployeeDetail] PRIMARY KEY CLUSTERED
(
[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
Facebook basically shows the data of your friends, the pages u liked, or the links u posted, commented or liked. That means each data what is are getting in your page is somehow related with you. It is basically the relationship between all these tables where the data is managed. Use join on the bases of userId and user friends userIds, you will get all the data you require.
I am using SQL Server 2008 to maintain a database where I have an userAcccounts table where the user details are stored while registering on the website. The userID column is an integer with identity on.
What I have noticed is that somehow, the column is skipping some ids (random number of ids, sometimes it skips 5,11,10 etc), i.e., the ID's are not consecutive. I have a read a similar question here, with a similar issue which suggested
"An identity sequence is incremented any time an insert is attempted
-- this includes a failed or rolled back INSERT"
I have checked my logs for errors, but there were no error during the period when the ids were skipped. Also my insert is not within any transaction for a rollback to happen, because there is no requirement of deleting an account. Also no other tables are involved during the registration
Although this is not a major issue as the ids will be unique nevertheless, what I would like to find out is why this behavior?
Perhaps I am overlooking something.
Are there any other scenarios where this kind of behavior can occur? i.e. the identity column skipping a few ids? Could this be an issue with concurrent access?
here is the table's create script.
CREATE TABLE [dbo].[UserAccounts](
[AccountID] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [varchar](30) NULL,
[LastName] [varchar](30) NULL,
[Gender] [varchar](10) NULL,
[Email] [varchar](150) NULL,
[EmailVerified] [bit] NULL,
[UserName] [varchar](30) NULL,
[Password] [varchar](50) NULL,
[ProfilePicture] [varchar](150) NULL,
[BackgroundPicture] [varchar](150) NULL,
[DateOfBirth] [smalldatetime] NULL,
[CreateDate] [smalldatetime] NULL,
[LastUpdatedOn] [smalldatetime] NULL,
[Points] [int] NULL,
[CurrentBadge] [varchar](30) NULL,
[FBID] [varchar](50) NULL,
[TwitterID] [varchar](50) NULL,
[Abused] [int] NULL,
[isActive] [bit] NULL,
[AccountTypeID] [int] NULL,
[DateStamp] [timestamp] NOT NULL,
[Location] [varchar](50) NULL,
[About] [varchar](250) NULL,
[UsingBackgroundPicture] [bit] NULL,
CONSTRAINT [PK__UserAcco__349DA5867F60ED59] PRIMARY KEY CLUSTERED
(
[AccountID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Any help in this regard is appreciated? Also if you require any other detail, please let me know.
Thanks
It's impossible to guarantee exact sequentiality of Sequences or IDs, without globally locking the entire database on every transaction -- to prevent any concurrent transactions, which could possibly also ask for an ID.
This would obviously reduce it to effectively a single-user database, and totally destroy performance.
For such reasons, there is explicitly no guarantee of continuous sequentiality.
I know that SimpleMembership will auto create the tables needed for authentication but I would much rather run the sql scripts at some time other than when the application is ran. Is there a download page for the SimpleMembership scripts?
I found a script on github
CREATE TABLE [dbo].[UserProfile] (
[UserId] INT IDENTITY (1, 1) NOT NULL,
[UserName] NVARCHAR (MAX) NULL,
PRIMARY KEY CLUSTERED ([UserId] ASC)
);
CREATE TABLE [dbo].[webpages_Membership] (
[UserId] INT NOT NULL,
[CreateDate] DATETIME NULL,
[ConfirmationToken] NVARCHAR (128) NULL,
[IsConfirmed] BIT DEFAULT ((0)) NULL,
[LastPasswordFailureDate] DATETIME NULL,
[PasswordFailuresSinceLastSuccess] INT DEFAULT ((0)) NOT NULL,
[Password] NVARCHAR (128) NOT NULL,
[PasswordChangedDate] DATETIME NULL,
[PasswordSalt] NVARCHAR (128) NOT NULL,
[PasswordVerificationToken] NVARCHAR (128) NULL,
[PasswordVerificationTokenExpirationDate] DATETIME NULL,
PRIMARY KEY CLUSTERED ([UserId] ASC)
);
CREATE TABLE [dbo].[webpages_OAuthMembership] (
[Provider] NVARCHAR (30) NOT NULL,
[ProviderUserId] NVARCHAR (100) NOT NULL,
[UserId] INT NOT NULL,
PRIMARY KEY CLUSTERED ([Provider] ASC, [ProviderUserId] ASC)
);
CREATE TABLE [dbo].[webpages_Roles] (
[RoleId] INT IDENTITY (1, 1) NOT NULL,
[RoleName] NVARCHAR (256) NOT NULL,
PRIMARY KEY CLUSTERED ([RoleId] ASC),
UNIQUE NONCLUSTERED ([RoleName] ASC)
);
CREATE TABLE [dbo].[webpages_UsersInRoles] (
[UserId] INT NOT NULL,
[RoleId] INT NOT NULL,
PRIMARY KEY CLUSTERED ([UserId] ASC, [RoleId] ASC),
CONSTRAINT [fk_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[UserProfile] ([UserId]),
CONSTRAINT [fk_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [dbo].[webpages_Roles] ([RoleId])
);
i have senerio like that
i have three table
department
[Dep_No_ID] [int] IDENTITY(1,1) NOT NULL,
[Dep_Name] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Dep_Code] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
test
[Test_ID] [int] IDENTITY(1,1) NOT NULL,
[Test_Code] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Test_Name] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Tests_DepartMent_Code] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Tests_Group_Code] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Tests_Rate] [decimal](18, 2) NULL,
and
sub_test
[Sub_Test_ID] [int] IDENTITY(1,1) NOT NULL,
[Sub_Test_Code] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Sub_Test_Name] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Sub_Tests_Test_Code] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Sub_Tests_DepartMent_Code] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Sub_Tests_Group_Code] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Sub_Test_Rate] [decimal](18, 2) NULL,
In my aspx page I show the Departments in a DropDownList when the user select the Department a request is going to server side and the Grid is bind with the Tests. And in this Gridview i have a Checkboxes in all rows when user check this check box a request is again going to the Server Side and second Gridview is bind with Subtests according to Tests,in all that ,Postback is occur is many times which decrease my efficiency because user select multiple test and Subtest from multiple department. Can any one give me idea,how i simlify this senerio by which minimum number of Postback occur
(in test and subtest grid i have 5-5 columns)
If you need quality and a well performing result, as well as if you can spend a little more time, jQuery with a good grid plug-in is the best option.
here's a good option.
jqGrid demos
UpdatePannel is a pretty bad option, which should be only considered when you have a limited time, not much concerned in performance, and when the page with less content.
You can make Jquery AJAX calls to get the conditional data or can use AJAX Update Panel instead.