SQL to Select a random row from a database table

Select a random row with MySQL: SELECT column FROM table ORDER BY RAND() LIMIT 1 Select a random row with PostgreSQL: SELECT column FROM table ORDER BY RANDOM() LIMIT 1 Select a random row with Microsoft SQL Server: SELECT TOP 1 column FROM table ORDER BY NEWID() Select a random row with IBM DB2 SELECT column, RAND() as IDX FROM table ORDER BY IDX FETCH FIRST 1 ROWS ONLY Select a random record with Oracle: SELECT column FROM ( SELECT column FROM table ORDER BY dbms_random.value ) WHERE rownum = 1 source link: http://www.petefreitag.com/item/466.cfm

Continue Reading

Insert Multiple Rows in SQL Server

In SQL Server 2005, in order to insert 3 rows to a table, you had to run 3 INSERT statements: insert into Customers (Name, City, Phone) values (‘Customer #1’, ‘Jerusalem’, ‘2343245’) insert into Customers (Name, City, Phone) values (‘Customer #2’, ‘Tel Aviv’, ‘0987345’) insert into Customers (Name, City, Phone) values (‘Customer #3’, ‘Haifa’, ‘275466’) In SQL Server 2008, you can insert multiple rows in a single insert statement that takes a number of value arrays: insert into Customers (Name, City, Phone) values (‘Customer #1’, ‘Jerusalem’, ‘2343245’), (‘Customer #2’, ‘Tel Aviv’, ‘0987345’), (‘Customer #3’, ‘Haifa’, ‘275466’) Source link

Continue Reading

OWA saves .docx and .xlsx file as .zip

The problem: When any Office 2007 attachment (.docx, .xlsx, etc) is opened from OWA, the user is asked to save the document before they open it. When they do this, the default extension is .zip. If the user changes it to the correct extension before opening, the file opens correctly. This happens because the Office 2007 MIME file types are not configured on the web server and the users browser does not know how to open the files. If IE is configured to open files based on the file header, it identifies the file as a zip, which is technically …

Continue Reading

Acordo ortográfico e Microsoft Word 2010

O novo acordo, que vai entrar em vigor até 2014, para activar a opção no Word 2010 Português basta navegar até ao Menu Ficheiro, seguido de Opções e item Verificação. Depois seleccionar a opção Modos de Português de Portugal : Pós-Acordo para converter textos automáticamente para o novo acordo ortográfico pode utilizar o programa Lince http://www.portaldalinguaportuguesa.org/index.php?action=lince

Continue Reading

IIS does not allow downloading files from .mdb format.

add the following to the web.config as follows: <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <system.webServer> <security> <requestFiltering> <fileExtensions allowUnlisted=”true” > <remove fileExtension=”.mdb” /> <add fileExtension=”.mdb” allowed=”true”/> </fileExtensions> </requestFiltering> </security> </system.webServer> </configuration> MIME Type must be registered on IIS

Continue Reading

Silverlight & SQL server connection

You can’t. Instead you should create a WCF service one server that Silverlight can talk to. Tutorial that does that: http://silverlight.net/learn/tutorials/sqldatagrid.aspx Your Silverlight app has two projects. One Aspx project for server side, one silverlight on client side. Your database resides on server side. You can access it from server side aspx project. Client side doesn’t know about database. You can use WCF for connection. Direct connection is not possible to the database.

Continue Reading

Error installing SQL Server 2008 Native Client (HRESULT:0x800736FD)

Problem solved changing the registry key. Ckeck if the “Windows Modules Installer” service is started. If not, and you receive an error “1450 Insufficient System resources” error, when trying to start it, then it is the origin of the problem. To solve it: 1) Open regedit and replace the following value: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control Key: RegistrySizeLimit Type: REG_DWORD Value: 0xFFFFFF (4294967295) 2) Reboot 3) Open a command prompt as administrator and run SFC /SCANNOW to check the integrity of system modules. 4) Install pending windows updates (surelly there are many of them)

Continue Reading

Changing the Framework on IIS7

Simple, but a little hidden: Open IIS Click on “Application Pools” : In the side panel (right) click on “Website” you want to change the framework: Sidebar, locate the “Edit Application Pool” and then click Basic Settings Clicking on “Basic Settings …” will appear the following selection screen FrameWork: Now, select the framework of your choice by clicking on the list. NET Framework Version: Once selected click “OK”

Continue Reading