The last time we posted “Install Microsoft SQL Server Compact 4.0”, Some friends feed backed they could not see anything about SQL Server Compact 4.0 in their Visual Studio 2010. Firstly, you have to upgrade your Visual Studio 2010 to sp1. However, after you upgrade and installed SQL Server Compact 4.0, you might still not [Read More ...]
How to select last 5 or 10 or … rows in a SQL Server data table ? Solution 1: This is the normal solution SELECT TOP N * FROM MyTable ORDER BY Id DESC Solution 2: Solution 1 is the normal way but when the data table is huge but the Id is not indexed, [Read More ...]
There are lots of ways to update a table data, here we have one example as the following: UPDATE HOSTDB SET InScan = NOWHOSTDB.InScan, Alarm1 = NOWHOSTDB.Alarm1, Alarm2 = NOWHOSTDB.Alarm2, Alarm3 = NOWHOSTDB.Alarm3, Alarm4 = NOWHOSTDB.Alarm4 FROM HOSTDB, NOWHOSTDB WHERE HOSTDB.idx = NOWHOSTDB.HOSTDBidx AND HOSTDB.idx = 1640
There was a coder wrote the following code about a SQL Server saving operation: public static bool SaveToDatabase(string strTab, string strSql, SqlConnection Sqlcn, DataSet ds) { SqlCommand comm = new SqlCommand(); comm.CommandText = strSql; comm.Connection = Sqlcn; comm.CommandType = CommandType.Text; SqlDataAdapter sda = new SqlDataAdapter(comm); SqlCommandBuilder scb = new [Read More ...]
There is a table structure here: CREATE TABLE [dbo].[FEEDBACK_LOG]( [Idx] [int] IDENTITY(1,1) NOT NULL, [FBIdx] [bigint] NOT NULL, [EventStatus] [int] NULL, [StartTime] [datetime] NOT NULL, [EndTime] [datetime] NOT NULL, [Length] [int] NOT NULL, CONSTRAINT [PK_FEEDBACK_LOG] PRIMARY KEY CLUSTERED ( [Idx] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS [Read More ...]
We have already had a post about “Clear ID counter after delete data table” which is just for reset identity column in SQL Server using Truncate command. However, Truncate is just the one method of resetting Identity in SQL Server, and it is only for the table which no foreign keys defined. If you use [Read More ...]
When we have huge data and we need to display data in client side page by page, the best way might be paging data in SQL Server side, otherwise the huge data retrieving will be ‘dead’ in your client side. Now we have a table as following: CREATE TABLE [dbo].[USER_EVENTS_LOG]( [LogEventsUserID] [int] IDENTITY(1,1) NOT NULL, [Read More ...]
For Microsoft languages developer, SQL Server 2005 / 2008 Management Studio Express is a required database management tool. But, at least for SQL Server 2005 / 2008 Management Studio Express, people all complained it is not easy to install, we always got error or trouble to install it. Here let us try to do one [Read More ...]
When you build an ASP.NET application, you might fee some boring works which you have to install a SQL Server database , no matter you can install SQL Server Express version, but you still have to install it. and also, if you want to try your application without using Visual Studio, you have to install [Read More ...]
We have already posted SQL DateTime Operations. Here we need another sample which is about how we should compare a SQL Server DateTime and a C# DateTime String: A sample here: StringBuilder sb = new StringBuilder(); sb.Append(“SELECT * FROM ViewAnalogCOSInfo” + ” WHERE EventStartTime >= ‘” + StartTime.ToString() + “‘” + ” AND [Read More ...]