Saturday, February 23, 2013

Select all user defined tables from database – SQL SERVER

There are different ways to select all User defined tables from databases

Option 1: Using Object Catalog view

   1: SELECT sobjects.name 
   2: FROM sysobjects sobjects
   3: WHERE sobjects.xtype = 'U'
   4: order by sobjects.name

Alternatively here is a list of other object types you can search for as well:


C: Check constraint
D: Default constraint
F: Foreign Key constraint
L: Log
P: Stored procedure
PK: Primary Key constraint
RF: Replication Filter stored procedure
S: System table
TR: Trigger
U: User table
UQ: Unique constraint
V: View
X: Extended stored procedure


Option 2: Using Information schema view



   1: SELECT * FROM INFORMATION_SCHEMA.TABLES 
   2: WHERE TABLE_TYPE = 'BASE TABLE'

Here is something you can do as well



   1: select * from sys.tables

Suppose you might need to get all tables from your SQL SERVER Instance. Here is what you can do



   1: --for all databases
   2: sp_msforeachdb 'select "?" AS db, * from [?].sys.tables'

Sunday, February 17, 2013

How to Set default button from C# to a Content Page

Here is how we can use default button property of the form to set Default Button for a content page from Code behind using C#
 
// Setting default button
this.Master.Page.Form.DefaultButton = this.btnSubmit.UniqueID;
 
Here is how we can set default button for the page which doesn’t have Master Page
// Setting Default Button           
this.Page.Form.DefaultButton = btnSubmit.UniqueID;
 
Hope this helps!!

Sunday, February 10, 2013

File Handling by Source Control

What are the files that needs to be check in VSS for better handling of files when we do development. There are many file types and are stored and updated internally for each developer based on their own settings. So in other words these files doesn’t need to be part of Source control system. Here are the list of file types that we might need to look in as developer

You can add the following files to Visual Studio source control:

  • Solution files (*.sln).

  • Project files, for example, *.csproj, *.vbproj files.

  • Application configuration files, based on XML, used to control run-time behavior of a Visual Studio project.

But the Files that you cannot add to source control include the following:

  • Solution user option files (*.suo).

  • Project user option files, for example, *.csproj.user, *.vbproj.user files.

  • Web information files, for example, *.csproj.webinfo, *.vbproj.webinfo, that control the virtual root location of a Web project.

  • Build output files, for example, *.dll and *.exe files.

For more information