All of a sudden i faced an issue where in i was forced to delete all the stored procedures in a database and recreate them.. if you are facing the same problem do check this out..
Just Run this script and once its executed successfully u'll see no sp in you database..
USEdatabasename GO
declare @procName sysname
declare someCursor cursor FOR SELECT name FROM sysobjects WHERE type='P'AND objectproperty(id,'IsMSShipped')=0
open someCursor fetch next FROM someCursor INTO @procName while @@FETCH_STATUS = 0 begin exec('drop proc ' + @procName) fetch next FROM someCursor INTO @procName end
close someCursor deallocate someCursor go
but be careful before running this script, always take a backup of the db before deleting all the sp's.
here is a sample xml file where different user names and passwords are stored, when a user logs into the web applications, the developer need to validate the credentials with the one present in the xml file.
Here goes the aspx.cs file code
This is all about validating the user credentials against the values stored in xml file
We know the importance of user friendly messages, when it comes to developing a windows applications, the application support
MessageBox.show("message goes here");
but this is not the case in web applications as there is no support for displaying a message box with a custom message directly.
So here is an alternative, we can make use of a javascript to display an alert box with the custom message.
To acheive the alert box functionality follow the steps :
1) Create a Alert.cs file in AppCode folder.
2) Copy & Paste the below code in the Alert.cs file
3) you can just call the show() from any .cs file in the project like this Alert.show("message");
using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;
/// /// Summary description for Alert /// public static class Alert { public static void show(string message) { string cleanMessage = message.Replace("'", "\\'"); string script = ""; Page page = HttpContext.Current.CurrentHandler as Page; if (page != null && !page.IsClientScriptBlockRegistered("alert")) { page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script); }
This query used to list all the tables present in the database
SELECT name FROM [servername].[databasename].dbo.sysobjects WHERE xtype='u' order by name
You can also select the other details like name, id, xtype, uid,info, status, base_schema_ver replinfo,parent_obj,crdate,ftcatid schema_ver,stats_schema_ver,type, userstat, sysstat, indexdel, refdate,version,deltrig,instrig updtrig,seltrig,category,cache
SELECT * FROM [servername].[databasename].dbo.sysobjects WHERE xtype='u'
Friday, April 10, 2009
Problem : we have a table in sql server and we have set a primary key to a column and auto increment is enabled, once u go on adding the records into the table the Identity column value is incremented by one, in case if u want to delete all the records in the table and re-insert the values the Identity column value will start from the previous value but not from zero.
Solution: To reset the Identity column value we have a command in sql
USE Databasename GO DBCC CHECKIDENT ('schema.tablename' , RESEED, 0) GO
On execution of this command successfully the below message is generated
Checking identity information: current identity value '0', current column value '0'. DBCC execution completed.