SQL Tutorial, SQL Server, SQL Statement, SQL Query, MS SQL 2000 Reporting Service, T-SQL, SQL Function, SQL Syntax, SQL User Define Function, SQL Trigger
Thursday, November 27, 2008
DBCC FREEPROCCACHE
DBCC FREEPROCCACHE WITH NO_INFOMSGS;
DBCC SQLPERF(logspace)
DBCC SQLPERF(logspace) is an absolutely functional command if you are only interested in consumption of your database log files. It provides the cumulative size for each log file for each database on the SQL Server instance as well as the amount of space consumed (as a percentage of total log file size). A drawback is the fact that the results are an aggregate for the database.
logspace can be 1 of the value below:UMSStats - SQL thread management
WaitStats - resources, wait types
IOStats - outstanding reads & writes (note: always zeros)
RAStats - read ahead activity (note: always returns zeros)
Threads - I/O / CPU / memory usage per thread
SpinLockStats - statistics on spinlocks
UMSSpinStats - statistics on UMS
NetStats - ODS statistics
LRUStats - LRU-MRU chain statistics (Note: free page scan always zero)
DBCC SHOWFILESTATS WITH NO_INFOMSGS
Friday, November 21, 2008
Get the ID of a Newly Inserted Row Using SCOPE_IDENTITY()
@@Identity will return the last identity value that was generated in the current session but in any scope.
If you database got trigger to insert a new row, @@Identity will give you the id that generated by trigger instead of ID of the last row you inserted.
In order to get the ID of the row that you inserted, which is just what SCOPE_IDENTITY() will give you.
Below is the SQL to get the last inserted ID in the current scope that need to execute together with the commands.
string sqlString = "INSERT INTO Table(Col1, Col2) VALUES (@Col1, @Col2); SELECT SCOPE_IDENTITY () As NewID";
SqlCommand objCmd = new SqlCommand(sqlString, MyConnection);
objCmd.Connection.Open();
objCmd.Parameters.Add(new SqlParameter("@Col1", Col1Value));
objCmd.Parameters.Add(new SqlParameter("@Col2", Col2Value);
SqlDataReader dataReader = objCmd.ExecuteReader();
if (dataReader.HasRows)
{
dataReader.Read();
newRowID = Convert.ToInt32(dataReader["NewID"]);
}
dataReader.Close();
Friday, November 14, 2008
SQL Update Multiple Columns
*****************
UPDATE Table1
SET (Col1, Col2, Col3, Col4) =
(SELECT Col1a, Col2a, Col3a, Col4a FROM Table2 WHERE Col5a=Table1.Col5)
WHERE Col5 IN (SELECT Col5a FROM Table2 )
*****************
Identity column not getting sequential values
Tuesday, October 7, 2008
Connect to Sql Server 2005 Express for Window SharePoint Service
Actualy you can't connect to WSS database remotely because network connectivity is disabled by default. ( or without SQL Server Agent Services not installed)
Thursday, August 21, 2008
The Hibernate Query Language - HQL
The simplest possible Hibernate query is of the form:
- "From Employee" - (similar to SQL "Select * From Employeetbl"
* Employee is a mapping class
if you map the table Employeetbl to a mapping class, so you can use the HQL to select from the mapping file.
Example of Mapping Class for NHibernate
<class table="Employeetbl" name="Employee" lazy="false">
<id type="string" column="Employeeid" name="Employeeid">
<generator class="increment">
</id>
<property type="string" column="EmployeeName" name="EmployeeName"></property>
</class>
Saturday, August 9, 2008
NHibernate
NHibernate uses the following ways to retrieve objects from the database:
- Hibernate Query Language (HQL)
- Query By Criteria (QBC) and Query BY Example (QBE) using Criteria API
- Native SQL queries
NHibernate can work on these Database
- Microsoft SQL Server 2005/2000
- Oracle
- Microsoft Access
- Firebird
- PostgreSQL
- DB2 UDB
- MySQL
- SQLite
NHibernate
Saturday, July 26, 2008
SQL Server Express Edition Comparison Table
Express Edition Products for SQL Server Compared | |||
| Feature | SQL Server 2005 Express Edition | SQL Server 2005 Express Edition with Advanced Services | SQL Server 2005 Express Edition Toolkit |
Database Engine | x | x | |
Client Components | x | x | x |
Full Text Search | x | ||
Reporting Services | x | ||
Management Studio Express | x | x | |
Business Intelligence Developer Studio | x | ||
Comparation between the SQL Server Database Between:
1. SQL Server 2005 Express Edition2. SQL Server 2005 Express Edition with Advanced Services
3. SQL Server 2005 Express Edition Toolkit
SQL Server 2005 Management Studio Express
The advanced query optimization engine of SQL Server 2005 delivers fast performance with full-text search. Load databases easily through the XCopy feature. Native XML support ensures that your Web environment can easily interoperate with other applications through Web services.
SQL Server 2005 Reporting Services provides a complete, server-based platform for creating, managing, and delivering traditional and interactive reports. Easily create sophisticated reports with tables, charts, and graphics, and then embed them in applications.
Configure SQL Server Express to dynamically tune database parameters to respond to changing usage characteristics. SQL Server Express delivers user updates directly using Microsoft Update, easily plugs in to most enterprise management environments, and supports either silent installs or GUI-based setup and installations.
SQL Server Express Edition
Friday, July 25, 2008
List of DBCC in SQL SERVER 2005
Example, maintenance, validation task and status checks.
DBCC CHECKALLOC - Check consistency of disk allocation.
DBCC CHECKCATALOG - Check catalog consistency
DBCC CHECKCONSTRAINTS - Check integrity of table constraints.
DBCC CHECKDB - Check allocation, and integrity of all objects.
DBCC CHECKFILEGROUP - Check all tables and indexed views in a filegroup.
DBCC CHECKIDENT - Check identity value for a table.
DBCC CHECKTABLE - Check integrity of a table or indexed view.
DBCC CLEANTABLE - Reclaim space from dropped variable-length columns.
DBCC dllname - Unload a DLL from memory.
DBCC DROPCLEANBUFFERS - Remove all clean buffers from the buffer pool.
DBCC HELP - Help for DBCC commands.
DBCC INPUTBUFFER - Display last statement sent from a client to a database instance.
DBCC OPENTRAN - Display information about recent transactions.
DBCC OUTPUTBUFFER - Display last statement sent from a client to a database instance.
DBCC PROCCACHE - Display information about the procedure cache
DBCC SHOW_STATISTICS - Display the current distribution statistics
DBCC SHRINKDATABASE - Shrink the size of the database data and log files.
DBCC SHRINKFILE - Shrink or empty a database data or log file.
DBCC SQLPERF - Display transaction-log space statistics. Reset wait and latch statistics.
DBCC TRACE - Enable or Disable trace flags
DBCC UPDATEUSAGE - Report and correct page and row count inaccuracies in catalog views
DBCC USEROPTIONS - Return the SET options currently active
DBCC deprecated commands
Thursday, July 24, 2008
New Feature in MySQL 6.0
2. Support for additional Unicode character sets: utf16, utf32, and 4-byte utf8. These character sets support supplementary Unicode characters; that is, characters outside the Basic Multilingual Plane (BMP).
3. BACKUP DATABASE and RESTORE statements for backup and restore operations.
4. Optimizer enhancements for faster subqueries and joins, including batched index access of table rows for sequences of disjoint ranges by the MyISAM and InnoDB storage engines.
5.The syntax for the LOCK TABLES statement has been extended to support transactional table locks that do not commit transactions automatically. Following LOCK TABLES ... IN SHARE MODE or LOCK TABLES ... IN EXCLUSIVE MODE, you can access tables not mentioned in the LOCK TABLES statement. You can also issue LOCK TABLES statements that acquire transactional locks many times in succession, adding additional tables to the locked set, and without unlocking any tables that were locked previously. When using LOCK TABLES with IN SHARE MODE or IN EXCLUSIVE MODE, tables are not unlocked until the transaction ends.
Transactional locks acquired with LOCK TABLES are released when the transaction ends, either explicitly with COMMIT or ROLLBACK, or implicitly due to a statement that causes implicit commit or because the connection ends.
6. Support for extended comments for tables, columns, and indexes.
More details, visit here http://dev.mysql.com/doc/refman/6.0/en/mysql-nutshell.html
SQLyog
Wednesday, July 9, 2008
LINQ to SQL in C#
Article will address the incorporation of LINQ to SQL into a win forms project, how to use LINQ to SQL to select, insert, update, and delete data, and how to use LINQ to SQL to execute stored procedures.
The article shows some simple examples of LINQ to SQL; from it you can see how easy it is to query against single and related tables and to write filtered queries, execute stored procedures, perform aggregation, and how to insert, update, and delete records from the database.
DataClasses1DataContext dc = new DataClasses1DataContext();
var q =
from a in dc.GetTable
where a.CustomerID.StartsWith("A")
orderby a.OrderDate ascending
select a;
dataGridView1.DataSource = q;
click here for full article
LINQ tutorials convert a Linq Query resultset to DataTable object
The tutorials attached with the source code
full article, click here
LINQ Begginer Tutorials
More Details, please visit the link
Thursday, June 26, 2008
Relational database management system (RDBMS)
A short definition of an RDBMS may be a DBMS in which data is stored in the form of tables and the relationship among the data is also stored in the form of tables.
Monday, June 23, 2008
Not be enough virtual memory - SQL Server
Solution
Use the -g startup parameter to leave additional, unreserved virtual memory available for these database allocations. The -g parameter is documented in the Readme.txt of the SQL Server 7.0 service pack, and in SQL Server 2000 Books Online. The "More Information" section in this article includes the settings that Microsoft recommends you use to determine the appropriate value for this setting.
Sql Server 2005 - Twelve Tips For Optimizing Query Performance
2. Use Clustered Indexes
3. Use Indexed Views
4. Use Covering Indexes
5. Keep your clustered index small.
6. Avoid cursors
7. Archive old data
8. Partition your data correctly
9. Remove user-defined inline scalar functions
10. Use APPLY
11. Use computed columns
12. Use the correct transaction isolation level
Original Article

