Skip to content

Instantly share code, notes, and snippets.

@ricardosiri68
Forked from anonymous/gist:6967341
Last active December 25, 2015 11:18
Show Gist options
  • Save ricardosiri68/6967370 to your computer and use it in GitHub Desktop.
Save ricardosiri68/6967370 to your computer and use it in GitHub Desktop.
ALTER PROCEDURE [dbo].[mostrarArchivos] (@Id_Usuario int, @Id_Carpeta int)
As
set nocount on
SELECT Id_Elemento = C.Id_Carpeta,
Elemento_Nombre = C.Carp_Nombre,
Tipo = 'Carpeta',
Modificado = '---'
FROM dbo.Usuario_Carpetas C
WHERE Id_Carpeta = @Id_Carpeta
AND Id_Usuario = @Id_Usuario
UNION
SELECT Id_Elemento = A.Id_Archivo,
Elemento_Nombre = A.Arc_Nombre,
--Esto Esta A Prueba
Tipo = tipoDisplay(A.Extencion),
Modificado = A.Arc_FechaCarga
FROM dbo.Usuario_Archivo A
WHERE Id_Carpeta = @Id_Carpeta
AND Id_Usuario = @Id_Usuario
ORDER BY
CASE
WHEN Tipo = 'carpeta' THEN 1
ELSE 0
END,
Elemento_Nombre;
CREATE FUNCTION tipoDisplay (ext CHAR(20)) RETURNS CHAR(20)
RETURN CASE WHEN ext = 'xls' OR ext = 'xlsx' THEN 'Excel'
WHEN ext = 'doc' OR ext = 'docx' THEN 'Word'
WHEN ext = 'ppt' OR ext = 'pptx' THEN 'Power Point'
WHEN ext = 'txt' THEN 'Bloc de notas'
WHEN ext = 'pdf' THEN 'PDF'
WHEN ext = 'jpg' OR ext = 'jpeg'
OR ext = 'gif' OR ext = 'png'
OR ext = 'bmp' THEN 'Imagen'
ELSE 'Otro (' + UPPER(ext) + ')' END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment