This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[fnGetSegunoEspacioFinal](@NombreCompleto as varchar(255)) | |
RETURNS int | |
AS | |
BEGIN | |
DECLARE @PosiSegunoEspacioFinal AS int | |
SET @PosiSegunoEspacioFinal = CHARINDEX(' ', @NombreCompleto, CHARINDEX(' ', @NombreCompleto) + 1) + 1 | |
RETURN @PosiSegunoEspacioFinal --La idea es marcar de forma generico el inicio de los apellidos en una cadena con el nombre completo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Calcula el primer día deseado de la semana del próximo mes, por ejemplo el primer domingo del próximo mes: | |
select primerDomEnProxMes from dbo.fnCalcProxDiaSemEnProxMes(getdate()) | |
*/ | |
CREATE FUNCTION [dbo].[fnCalcProxDiaSemEnProxMes]( | |
@D Datetime | |
) | |
RETURNS @output TABLE(primerDomEnProxMes datetime, primerLunEnProxMes datetime, primerMarEnProxMes datetime, primerMieEnProxMes datetime, primerJueEnProxMes datetime, primerVieEnProxMes datetime, primerSabEnProxMes datetime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[fnExtraerEmails] (@email varchar(255)) | |
RETURNS VARCHAR(255) | |
AS | |
BEGIN | |
declare @Izda varchar(255); | |
declare @RevIzda varchar(255); | |
declare @Dcha varchar(255); | |
declare @resultado varchar(255); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[CapitalizeFirstLetter] | |
( | |
--string need to format | |
@string VARCHAR(200)--increase the variable size depending on your needs. | |
) | |
RETURNS VARCHAR(200) | |
AS | |
BEGIN | |
--Declare Variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Ver: https://stackoverflow.com/questions/37359161/how-would-i-make-a-yes-no-prompt-in-console-using-c | |
bool confirmed = false; | |
string Key; | |
do { | |
Console.Write("Please enter a login key: "); | |
Key = Console.ReadLine(); | |
Console.WriteLine("You entered, " + Key + " as your login key!"); | |
ConsoleKey response; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT t.NAME AS NombreTabla, | |
s.Name AS Esquema, | |
p.rows AS NumFilas, | |
SUM(a.total_pages) * 8 AS EspacioTotal_KB, | |
(SUM(a.total_pages) * 8)/ 1024 AS EspacioTotal_MB, | |
((SUM(a.total_pages) * 8)/ 1024/1024) AS EspacioTotal_GB, | |
SUM(a.used_pages) * 8 AS EspacioUsado_KB, | |
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS EspacioNoUsado_KB | |
FROM sys.tables t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Al vaciar la tabla | |
delete NombreTabla | |
DBCC CHECKIDENT ('NombreTabla', RESEED, 0); | |
-- Al siguiente valor | |
declare @max int | |
SELECT @max=max([Id]) FROM NombreTabla | |
if @max IS NULL | |
SET @max = 0 | |
DBCC CHECKIDENT ('[NombreTabla]', RESEED, @max) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TRIGGER [dbo].[NombreTrigger_UpdIns] ON [dbo].[NombreTabla] | |
FOR UPDATE, INSERT AS | |
UPDATE NombreTabla | |
SET UserName = coalesce(suser_sname(),'?'), | |
UserDateTime = GETDATE() | |
WHERE id IN (SELECT DISTINCT id FROM Inserted) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For Each c As Object In Form1.Controls | |
If c.GetType Is GetType(TextBox) Then | |
AddHandler DirectCast(c, TextBox).TextChanged, AddressOf CamposForm_TextChanged | |
End If | |
Next | |
Sub CamposForm_TextChanged(ByVal sender As TextBox, ByVal e As System.EventArgs) | |
CamposCambiados.Value = CamposCambiados.Value & IIf(CamposCambiados.Value <> "", ", " & sender.ID, sender.ID) | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Ext | |
{ | |
public static bool In<T>(this T t, params T[] values) | |
{ | |
foreach (T value in values) | |
{ | |
if (t.Equals(value)) | |
{ | |
return true; | |
} |
NewerOlder