Archive for February, 2010

How execute store procedure with C#.net

Create store procedure in sql query analyser CREATE PROCEDURE sp_chkadmin @login_id varchar(50), @password varchar(50) as begin select * from where login_id = @login_id and password =@password end GO protected void butlogin_ServerClick1(object sender, EventArgs e) { string username = txtlogin.Value.ToString().Replace(“‘”, “””); string password = txtpassword.Value.ToString().Replace(“‘”, “””); int isUserExist=0; isUserExist = IsUserExist(username, password); if (isUserExist == 1) [...]

How use trigger in sql

Example of Delete trigger CREATE trigger [TRIGGER_Deletesubcategory] ON dbo.category FOR delete AS declare @nmid int select @nmid=sno from deleted delete from subcategory where cat_id= @nmid There will be two table one is category and second one is subcategory and the primery key of category table will be sno and the this will foreign key(cat_id) for [...]

Return Multi Row value in a single column with comma seprated

Return Multi Row value in a single column with comma seprated using sql I want Return output like 1,2,3,4,5 using sql. There is one table in which has column id name 1 Dilip 2 Dinesh 3 Varun 4 Dhanpat 5 Renuka solution: declare @a varchar(500) set @a = ‘ ‘ select @a = @a + [...]

Check the column value if value is in string format with coma separated using Sql

If column value is in 1,2,34,23,44,444,12,23,… format than how can check the value using like operator in Sql. means if the coma separated value is in column in any table then how can check the value using like operator in Sql. solution: select * from s where sid like ’44,%’ or sid like ‘%,44,%’ or [...]

Searching table from database using sql

This article demonstrate how to search a table in database using sql query :- Solution:- select * from information_schema.tables where table_name like ‘%abc%’ where abc is table name