Showing posts with label SQL Commands. Show all posts
Showing posts with label SQL Commands. Show all posts

Tuesday, 8 November 2011

How to break the connection string into elements

Question Received:
        How to split the connection string into individual elements
like InitialCatalog, DBName, UserName, Passwd..

Solution:
       To break the conn. String, use the SQLConnectionBuilder as,
        SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder("");
        builder="AnyConnectionString";
        String DBName = builder.IntialCatalog.ToString();

Monday, 8 August 2011

SQL Commands for Retrieving Row Number


Issue:
     To Retrieve the Row Number for a particular record in the database.

Soln:
     Create table temp (name varchar(30));

     insert into temp values('ashok');
     insert into temp values('king');
     insert into temp values('tekken');
     insert into temp values('manik');
     insert into temp values('DayLight');

     ALTER TABLE temp
     ADD rownumber number null;

     UPDATE temp SET rownumber= ROWNUM;

     SELECT rownumber, NAME FROM temp WHERE NAME LIKE 'tekken';

     ALTER TABLE temp DROP COLUMN rownumber;