Skip to main content

Posts

How to TRUNCATE all tables in Microsoft SQL SERVER instance

When we are developing some software and we want to clean the SQL database to simulate a new installation, it would be interesting to have a routine that would erase the contents of all tables. This script performs this task, it deletes the contents of all the tables of the instance that is open in SQL Server Management Studio.  ATTENTION: The TRUNCATE command erases all the contents of the tables and there is no way to restore, only with backup.  Use this script very consciously and in test environments where you really want to do a general clean up in your database.  I am not responsible for the use of this in your bank.  Created by my friend  Airton Junior  , it follows the killer script...  USE MASTER; --TABELA TEMPORÁRIA PARA ARMAZENAR OS BANCOS SEPARADOS PARA LIMPEZA CREATE TABLE #TEMPORARIA (NOMEBANCO VARCHAR(255)); GO --SEPARATION OF DATABASES INSERT INTO #TEMPORARIA (NOMEBANCO) SELECT name FROM master.sys.databases WHERE name LIK...

How to search for commands that have already been executed on the Microsoft SQL Server instance.

Hi, With the query below it is possible to view commands that have already been executed in the SQL SERVER instance. SELECT DMExQryStats.last_execution_time AS [Executed At], DMExSQLTxt.text AS [Query] FROM sys.dm_exec_query_stats AS DMExQryStats CROSS APPLY sys.dm_exec_sql_text(DMExQryStats.sql_handle) AS DMExSQLTxt ORDER BY DMExQryStats.last_execution_time DESC If you want to check for especificios commands, add the WHERE clause to search the command content. Example: If you want to search all UPDATES performed in your database, add this clause WHERE WHERE lower(substring(DMExSQLTxt.text,1,6))='update'

How to create a query that returns the first day of the month and the last day of the month using GETDATE() Microsoft SQL SERVER.

 QUERY:  SELECT DATEADD(month, DATEDIFF(month, -1, getdate()) - 2, 0) as Primeirodiadomes,     DATEADD(ss, -1, DATEADD(month, DATEDIFF(month, 0, getdate()), 0)) as Ultimodiadomes RESULT :

How to deploy a printed pages control in the VFP to take an action after the report prints.

Isolved this issue by creating a public variable: PUBLIC _npagetotal _npagetotal = 0 Then, using the ReportListener component to control the reports, analyze the pagetotal property after the report runs.  If it returns <> 0, it means there was content in the report and if it returns 0 (zero), there was no content. */ control of printed pages _npagetotal = 0 LOCAL loreportlistener loreportlistener = CREATEOBJECT("ReportListener") loreportlistener.LISTENERTYPE = 0 loreportlistener.QUIETMODE = .T. REPORT FORM pathgeral + '\report\danfe_nfce_2.frx' OBJECT loreportlistener        _npagetotal = loreportlistener.pagetotal RELEASE loreportlistener IF _npagetotal<> 0 THEN   * PERFORMS AN ENDIF  ACTION

ReportListener object in VFP

This file is available on FOXWIKI and talks a lot about the ReportListener component.  The article is in English. Here's an introduction and link to access. The Fox Development Team did an "Excellent" job with VFP 9.0!  Hearing our "screams in the wilderness", they introduced a radically different approach to reporting.  It is not strictly object-oriented (as some may have wished), but it is "object-enhanced" and I believe that if you educate yourself and keep an open mind, you will find a wealth of opportunities. http://fox.wikis.com/wc.dll?Wiki~ReportListener

How to add an image or caption in the listbox component.

This post shows how to get the result shown in the image below: It's quite simple, just create the images observing the height in pixels that you want to have in the listbox.  The height in pixels of the image will define the line spacing.  Knowing this, just create the necessary images and add them to the project. But how to make them appear in the listbox? Suppose your listbox component is called LSTCOTACAO, the code would look like this: THISFORM.lstcotacao.CLEAR() && To clear THISFORM.lstcotacao.ADDITEM('Your text') && Text that will appear in the line THISFORM.lstcotacao.PICTURE(.LISTCOUNT) = 'legenda_branca.png' && Image that will be added to the line just inserted

How to change color according to cell value in Visual Foxpro grid.

This post teaches you how to get the effect shown in the image below using the GRID component of visual fox pro. Requires visual foxpro 9.0 SP2 I usually create a class for this, but here in the example I will do it in the simplest way, however, using a method inside the form. You need to create a blank form, add a GRID, a REFRESH button and add a table.  In my example I used a very basic table, called VALORES.DBF, with the VALOR field.  If the value is 1, I use one color, if it is 2, I use another and so on. My VALORES.DBF table is in the same directory where I am saving the FORM.  Creating the table CREATE TABLE values ​​(n(10,2) value) INSERT INTO values ​​(value) VALUES (1) INSERT INTO values ​​(value) VALUES (2) INSERT INTO values ​​(value) VALUES (3)  FORM PROPERTIES BINDCONTROLS = .F. DATASESSION = 1  INIT SELECT values LOCATE THISFORM.BINDCONTROLS = .T.  LOAD METHOD IF NOT FILE('values.dbf') SET MESSAGE TO MESSAGEBOX('Table VALORES.DBF is not...