Monday, April 8, 2013

How To View The Definition Of A Stored Procedure In Sql


To View The Definition Of A Stored Procedure In Transact Sql Using Query Editor


USE DatabaseName;
GO
EXEC sp_helptext N'DatabaseName.dbo.ProcedureName';

What Is The Connection String To Connect The Excel File With Extensions .XLS or .XLSX or .CSV in C#, ASP.Net ?


Connection Strings to Read XLS And XLSX And CSV File In C#,ASP.NET



To Upload CSV File:

string CSVconnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPathofFileCsv + @";Extended Properties='text;HDR=Yes;FMT=Delimited(,)';";

To Upload XLS File:


string XLSconnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source= " + strPathofFileXls + ";Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1\"";

To Upload XLSX File:


string XLSXconnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strPathofFileXlsx + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";";


                        



Saturday, April 6, 2013

How to Delete All Stored Procedure From A Database At a Time


declare cur_dropProc cursor
scroll for
select [name] from sysobjects where xtype='p'



open cur_dropProc
go
Declare @procName varchar(500)
fetch first from cur_dropProc into @procName
while @@fetch_status=0
begin
Exec('drop procedure ' + @procName)
fetch next from cur_dropProc into @procName
end
go
close cur_dropProc
go
deallocate  cur_dropProc

How To Delete All Tables In A Database Using sql


To Delete All Tables In A Database At a time Using One Query.

USE [database name]
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

How To Get All Table Names In A Database Using sql.

Here Is The Best Way To Get All Table Names , Procedure Names , Views etc.., Using Following Query.



SELECT sobjects.name
FROM sysobjects sobjects
WHERE sobjects.xtype = 'U'

And For Other Object Types


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

Wednesday, March 20, 2013

Starting This Blog With a Great Hope And Happiness To share My Knowledge with others....Please Correct me if i post any wrong or incorrect code.

Friday, February 18, 2011

institute list with city

SELECT ISI.INST_ID,II.INST_NAME,CM.COURSE_NAME,SCM.SUB_COURSE_NAME,
RIGHT(II.INST_PHONE, LEN(II.INST_PHONE) - 4) AS INST_PHONE,
RIGHT(II.INST_MOBILE, LEN(II.INST_MOBILE)-4) AS INST_MOBILE,
II.INST_ADDR_1,II.INST_ADDR_2,II.INST_CONTACT_NAME,CIM.CITY_NAME FROM INST_SUBCOURSE_INFO ISI
INNER JOIN INST_INFO II ON II.INST_ID = ISI.INST_ID
INNER JOIN COURSE_MST CM ON CM.COURSE_ID = ISI.COURSE_ID
INNER JOIN SUB_COURSE_MST SCM ON SCM.SUB_COURSE_ID = ISI.SUB_COURSE_ID
INNER JOIN CITY_MST CIM ON CIM.CITY_ID = II.INST_CITY_ID
WHERE II.INST_STATUS=1 AND ISI.inst_course_status=1 AND CM.COURSE_STATUS=1 AND SCM.SUB_COURSE_STATUS=1

ORDER BY II.INST_ID