Skip to main content

Posts

Showing posts from 2008

SQL SERVER - 2005 - List All The Constraint of Database - Find Primary Key and Foreign Key Constraint in Database

Following script are very useful to know all the constraint in the database. I use this many times to check the foreign key and primary key constraint in database. This is simple but useful script from my personal archive. SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint, SCHEMA_NAME(schema_id) AS SchemaName, OBJECT_NAME(parent_object_id) AS TableName, type_desc AS ConstraintType FROM sys.objects WHERE type_desc LIKE '%CONSTRAINT' We can also use following query: select Referencing_Object_name, referencing_column_Name, Referenced_Object_name, Referenced_Column_Name from (select Referenced_Column_Name = c.name, Referenced_Object_name = o.name, f.constid from sysforeignkeys f, sysobjects o, syscolumns c where (f.rkeyid = o.id) and c.id = o.id and c.colid = f.rkey) r, (select referencing_column_Name = c.name, Referencing_Object_name = o.name, f.constid from sysforeignkeys f, sysobjects o, syscolumns c where (f.fkeyid = o.id) and c.id = ...

How to import data from an Excel Sheet to sql server using .NET

SUMMARY This article discusses how you can use ADO.NET to retrieve data from a Microsoft Excel workbook, modify data in an existing workbook, or add data to a new workbook. To access Excel workbooks with ADO.NET, you can use the Jet OLE DB provider; this article provides the information that you need so that you can use the Jet OLE DB provider when Excel is the target data source. How to Use the Jet OLE DB Provider With Microsoft Excel Workbooks The Microsoft Jet database engine can access data in other database file formats, such as Excel workbooks, through installable Indexed Sequential Access Method (ISAM) drivers. To open external formats supported by the Microsoft Jet 4.0 OLE DB Provider, specify the database type in the extended properties for the connection. The Jet OLE DB Provider supports the following database types for Microsoft Excel workbooks: Excel 3.0 Excel 4.0 Excel 5.0 Excel 8.0 NOTE : Use the Excel 5.0 source database type...
Those who have a GMail account probably recognize its similarity to the attachment feature when composing new email. Since Gmail’s javascript seems to be hidden… or scrambled… or… whatever they did to it, I was left in the dark trying to figure this one out on my own. See the below Code: <input type="hidden" value="0" id="theValue" /> <p><a href="javascript:;" onclick="addElement();">Add Some Elements</a></p> <div id="myDiv"> </div> The hidden input element simply gives you a chance to dynamically call a number you could start with. This, for instance could be set with PHP or ASP. The onclick event handler is used to call the function. Lastly, the div element is set and ready to receive some children appended unto itself (gosh that sounds wierd). Add Element Javascript Function: function addElement() { var ni = document.getElementById('myDiv'); var numi = document.get...