Posts

MSSQL - how to change "SA" password

1. Open the "SQL Server Enterprise Manager". This is usually under "Start"-->"Programs"-->"Microsoft SQL Server". 2. Navigate to the "Logins" object under the "Security" folder on the SQL Server you wish to administer. Then, right click on the 'sa' account and select "Properties". 3. Now, enter a new password in the "Password" field under the "Authentication" options. website reference: http://www.eukhost.com/forums/f31/how-change-mssql-sa-password-511

MSSQL - select a random row

Microsoft SQL Server provide function "NEWID()" to random record from database. Let's see example. SELECT TOP 1 column FROM table ORDER BY NEWID() Example: SELECT TOP 1 code_item FROM game_item WHERE available=1 ORDER BY NEWID()

MSSQL - how to select all table name

In Oracle, you can use statement "select * from tab" for get all table name in your database. But for MSSQL you have to use "select * from sys.Tables" instead of "tab". Example. USE nothwinds SELECT * FROM SYS.TABLES

HTML - Image Lightbox

Image
If you need to show the full size overlay image on the current page. "Lokesh Dhakar"'s coding is a good example. His code is on javascript and stylesheet. Please visit Lokesh's site to download & see the example. URL Reference: http://www.huddletogether.com/projects/lightbox2/ Example: if you click on thumbnail image. You'll get the full image like this.

MSSQL - Reset Identity Column Value in SQL Server

Command to reset identity column: DBCC CHECKIDENT(table_name,RESEED,0) 1 is the next value of your identity column. Example. Column "id" in table "customer" is an identity column. DBCC CHECKIDENT("customer",RESEED,0) -> next id is 1. or DBCC CHECKIDENT("customer",RESEED,10) -> next id is 11. If you need to check next ID you can use DBCC CHECKIDENT("customer",NORESEED) -> you'll get these result. "Checking identity information: current identity value '0', current column value '0'. DBCC execution completed. If DBCC printed error messages, contact your system administrator." Or you can use this SQL statement to get the current identity: Example. SELECT IDENT_CURRENT ('customer') AS Current_Identity

javascript - show/hide div section

< script language = "javascript" > function toggle ( ) { var ele = document. getElementById ( "toggleText" ) ; var text = document. getElementById ( "displayText" ) ; if ( ele. style . display == "block" ) { ele. style . display = "none" ; text. innerHTML = "show" ; } else { ele. style . display = "block" ; text. innerHTML = "hide" ; } } </ script >   <a id="displayText" href="javascript:toggle();">show</a> <== click Here <div id="toggleText" style="display: none"><h1>peek-a-boo</h1></div> web reference: www.randomsnippets.com

MSSQL - show data per page

- This statement will return record 1 to 20. SELECT * FROM ( SELECT row_number() OVER (ORDER BY id) AS rownum, * FROM example_table_a ) AS A WHERE A.rownum BETWEEN (1) AND (20) - If you want the next 20, your where criteria should be: WHERE A.rownum BETWEEN (21) AND (40) - Finally, SQL statement in your C# code will be: public String CreateSQL(Int32 pageNo, Int32 pageSize) {      StringBuilder _sbSQL = new StringBuilder();      Int32 _offset = 1+ ((pageNo-1) * pageSize);      _sbSQL.Append(" SELECT * FROM ");      _sbSQL.Append(" ( ");      _sbSQL.Append(" SELECT row_number() OVER (ORDER BY id) AS rownum, * ");      _sbSQL.Append(" FROM example_table_a ");      _sbSQL.Append(" ) AS A ");      _sbSQL.Append(" WHERE A.rownum BETWEEN (" + _offset +") AND (" + (_offse...