{"text_format":"1","workbook":"xlsx","n_sheets":7,"sheets":["DESCRIBE","CREATE_TABLE","greatest-n-per-group","CAST_CONVERT","MATH","DATE","config"],"not_rendered":{"charts":0,"images":0,"macros":1,"external_links":0,"defined_names":8,"comments":0,"pivot_tables":0},"unopened":[],"bounds":{"document_bytes":16777216,"sheet_cells":100000,"rows_first":2000,"rows_last":500,"rows_between":2000,"halvings":0,"cell_chars":16384,"cell_head_chars":4096},"cells_cut":0,"cells_raw":0,"read":"whole","date_system":"1900"}

{"sheet":"DESCRIBE","index":0,"n_rows":294,"n_cols":32,"rows_kept":294,"cut":false,"hidden":false,"merged":[]}
["SQL_Server_documentation_Help.pdf"]
["View the Table Definition",null,"pp.3061"]
[]
["Get list of databases from SQL Server",null,null,null,"List Tables",null,null,null,null,"Describe table"]
["https://stackoverflow.com/questions/147659/get-list-of-databases-from-sql-server",null,null,null,null,null,null,null,null,"https://stackoverflow.com/questions/319354/what-is-the-equivalent-of-describe-table-in-sql-server"]
[null,null,null,null,null,null,null,null,null,"MyDatabaseName"]
["MyDatabaseName",null,null,null,"MyDatabaseName",null,null,null,null,"SELECT *"]
["SELECT name",null,null,null,"SELECT *",null,null,null,null,"FROM  INFORMATION_SCHEMA.COLUMNS"]
["FROM master.sys.databases",null,null,null,"FROM INFORMATION_SCHEMA.TABLES",null,null,null,null,"WHERE table_name LIKE '%LAB_%'"]
[null,null,null,null,null,null,null,null,null,"order by ordinal_position"]
["Columna1",null,null,null,"Columna1","Columna2","Columna3","Columna4"]
["master",null,null,null,null,null,null,null,null,"DATABASE","TABLE_SCHEMA","TABLE_NAME","TABLE_TYPE","ORDINAL_POSITION","COLUMN_DEFAULT","IS_NULLABLE","DATA_TYPE","CHARACTER_MAXIMUM_LENGTH","CHARACTER_OCTET_LENGTH","NUMERIC_PRECISION","NUMERIC_PRECISION_RADIX","NUMERIC_SCALE","DATETIME_PRECISION","CHARACTER_SET_CATALOG","CHARACTER_SET_SCHEMA","CHARACTER_SET_NAME","COLLATION_CATALOG","COLLATION_SCHEMA","COLLATION_NAME","DOMAIN_CATALOG","DOMAIN_SCHEMA","DOMAIN_NAME"]
["tempdb"]
["Northwind"]
["BikeStores"]
[]
[]
[]
[]
[]
[]
[]
["Find all tables containing column with specified name - MS SQL Server"]
["https://stackoverflow.com/questions/4849652/find-all-tables-containing-column-with-specified-name-ms-sql-server"]
["AdaTheDev, Jan 31 '11 [130k] [2165 up]"]
[]
["Search Tables:"]
[]
["SELECT      c.name  AS 'ColumnName'"]
["            ,t.name AS 'TableName'"]
["FROM        sys.columns c"]
["JOIN        sys.tables  t   ON c.object_id = t.object_id"]
["WHERE       c.name LIKE '%MyName%'"]
["ORDER BY    TableName"]
["            ,ColumnName;"]
[]
["Search Tables and Views:"]
[]
["SELECT      COLUMN_NAME AS 'ColumnName'"]
["            ,TABLE_NAME AS  'TableName'"]
["FROM        INFORMATION_SCHEMA.COLUMNS"]
["WHERE       COLUMN_NAME LIKE '%MyName%'"]
["ORDER BY    TableName"]
["            ,ColumnName;"]
[]
["----"]
["@Revious INFORMATION_SCHEMA views included in SQL Server comply with the ISO standard definition for the INFORMATION_SCHEMA."]
["http://technet.microsoft.com/en-us/library/ms186778.aspx"]
[]
["sys.columns, sys.tables is Microsoft Sql Server specific."]
["Tomasito, Mar 18 '14 [1765] [20 up]"]
["----"]
["Including TABLE_SCHEMA in your select list can be helpful. Still +1 because it's a good answer. "]
["Bernhard Hofmann Oct 22 '14 [9865] [6 up]"]
["----"]
["get a table scheman also: SELECT c.name AS ColName, t.name AS TableName, SCHEMA_NAME(t.schema_id) AS SchemaName .... –"]
["Skorunka František Oct 6 '16 [4164] [2 up]"]
[]
["MyDatabaseName"]
["SELECT      c.name  AS 'ColumnName'"]
["            ,t.name AS 'TableName'"]
["FROM        sys.columns c"]
["JOIN        sys.tables  t   ON c.object_id = t.object_id"]
["WHERE       c.name LIKE '%cliente%'"]
["ORDER BY    TableName"]
["            ,ColumnName;"]
[]
["Col_Name","Table_Name"]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
["Khwaza Bandenawaz, Oct 18 '11 [3939] [393 up]"]
["We can also use the following syntax:-"]
[null,null,null,null,"---"]
["MyDatabaseName",null,null,null,"This worked for me and the top answer didn't (I'm using MariaDB). – Aubrey Robertson, Nov 10 '16 [217] [13 up]"]
["select * from INFORMATION_SCHEMA.COLUMNS ",null,null,null,"---"]
["where COLUMN_NAME like '%cliente%' ",null,null,null,"Not surprising it works on all those different databases given that INFORMATION_SCHEMA is part of the ANSI Standard. Davos, May 24 '18 [3956] [6 up]"]
["order by TABLE_NAME",null,null,null,"https://en.wikipedia.org/wiki/Information_schema"]
[]
["Columna1","Columna2","Columna3","Columna4","Columna5","Columna6","Columna7","Columna8","Columna9","Columna10","Columna11","Columna12","Columna13","Columna14","Columna15","Columna16","Columna17","Columna18","Columna19","Columna20","Columna21","Columna22","Columna23"]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
["Todd-ECU, Sep 22 '15 [2219] [207 up]"]
["SQL Server:",null,null,null,"Oracle:"]
[null,null,null,null,"SELECT owner, table_name, column_name "]
["MyDatabaseName",null,null,null,"FROM all_tab_columns "]
["SELECT Table_Name, Column_Name ",null,null,null,"WHERE column_name LIKE '%YOUR_COLUMN_NAME%'"]
["FROM INFORMATION_SCHEMA.COLUMNS",null,null,null,"AND OWNER IN ('YOUR_SCHEMA_NAME');"]
["WHERE TABLE_CATALOG = 'MyDatabaseName'"]
["AND COLUMN_NAME LIKE '%cliente%'",null,null,null,"---"]
[null,null,null,null,"This should really be the accepted answer. You don't have to perform joins which makes it much easier than the accepted answer – Kellen Stuart [4987] [3 up]"]
["Table_Name","Column_Name"]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
["MarredCheese, Mar 2 '20 [10.1k] [12 up]"]
["I wanted something for tables and views that didn't make my eyes bleed."]
[]
["Type        Object   Column"]
["----------------------------"]
["BASE TABLE  Table1   myName1"]
["BASE TABLE  Table2   myName2"]
["VIEW        View1    myName1"]
["VIEW        View2    myName2"]
[]
[]
["MyDatabaseName"]
["SELECT"]
["    t.TABLE_TYPE AS [Type],"]
["    c.TABLE_NAME AS [Object],"]
["    c.COLUMN_NAME AS [Column]"]
["FROM"]
["    INFORMATION_SCHEMA.COLUMNS AS c"]
["    LEFT JOIN INFORMATION_SCHEMA.TABLES AS t ON"]
["        t.TABLE_CATALOG = c.TABLE_CATALOG AND "]
["        t.TABLE_SCHEMA = c.TABLE_SCHEMA AND"]
["        t.TABLE_NAME = c.TABLE_NAME"]
["WHERE"]
["    c.COLUMN_NAME LIKE '%cliente%'"]
["ORDER BY"]
["    [Type],"]
["    [Object],"]
["    [Column]"]
[]
["Columna1","Columna2","Columna3"]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
["DROP TABLE IF EXISTS"]
[]
["[BikeStores Sample Database - drop all objects.sql]"]
[]
[" --Posiblemente esta sintaxis require unha versión de SQL Server superior á que estou usando (2008 R2)"]
["DROP TABLE IF EXISTS sales.order_items;"]
[]
["[000_SELECT - INTO Clause (Transact-SQL).docx]"]
[null,null,null,null,null,null,null,null," --or you could use IF EXISTS(OBJECTID('TABLEA','U'))"]
["MyDatabaseName",null," --OK",null,null,null,"MyDatabaseName",null," --FALLA"]
["IF EXISTS(select 1 from sys.objects where name = 'TABLEA' and type = 'U')",null,null,null,null,null,"IF EXISTS(OBJECTID('TABLEA','U'))"]
["BEGIN",null,null,null,null,null,"BEGIN"]
["DROP TABLE TABLEA",null,null,null,null,null,"DROP TABLE TABLEA"]
["END",null,null,null,null,null,"END"]
[]
["Columna1",null,null,null,null,null,"Columna1"]
[]
[]
["[000_Tutorial_Escritura_de_instrucciones_Transact-SQL.docx]"]
[]
["TRUNCATE TABLE"]
["Ejecute el comando siguiente para eliminar todas las filas de la tabla:"]
[]
["MyDatabaseName",null," --OK",null,"MyDatabaseName",null," --OK"]
["TRUNCATE TABLE [MyDatabaseName].dbo.TABLEA;",null,null,null,"INSERT [MyDatabaseName].dbo.TABLEA VALUES (1);"]
[null,null,null,null,"INSERT [MyDatabaseName].dbo.TABLEA VALUES (2);"]
[null,null,null,null,"INSERT [MyDatabaseName].dbo.TABLEA VALUES (3);"]
[null,null,null,null,"INSERT [MyDatabaseName].dbo.TABLEA VALUES (4);"]
[]
["Columna1",null,null,null,"Columna1"]
[]
[]
[]
["MyDatabaseName"]
["SELECT USER AS [USUARIO ACTUAL], USER_ID() AS [ID], HAS_DBACCESS('MyDatabaseName2') AS [ACCESO A BASE DE DATOS];"]
[]
[]
[]
[]
["Columna1","Columna2","Columna3"]
["dbo",1,1]
[]
["MyDatabaseName"]
["SELECT SUSER_SID() AS [SID], SUSER_SNAME() AS [NOMBRE DE INICIO DE SESION DEL SID];"]
[]
[]
[]
[]
["Columna1","Columna2","Columna3"]
[null,"sa"]
[]
["MyDatabaseName",null,"Configuration Functions (Transact-SQL)"]
["SELECT @@VERSION, @@LANGUAGE, @@SERVERNAME;"]
[]
[]
[]
[]
["Columna1","Columna2","Columna3"]
["Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (Intel X86) \n\tApr  2 2010 15:53:02 \n\tCopyright (c) Microsoft Corporation\n\tExpress Edition with Advanced Services on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)\n","Español","EQUIPO"]
[]
["SQL_Server_documentation_Help.pdf"]
["Ver: Metadata Functions (Transact-SQL)"]
["Ver: Security Functions (Transact-SQL)"]
["Ver: System Functions (Transact-SQL)"]
["Ver: System Statistical Functions (Transact-SQL)"]
[]
["MyDatabaseName",null,null,"MyDatabaseName"]
["SELECT HOST_NAME();",null,null,"SELECT @@CONNECTIONS;"]
[]
[]
[]
[]
["Columna1",null,null,"Columna1"]
["EQUIPO",null,null,254]
[]
[]
["EXECUTE (Transact-SQL)"]
["Using EXECUTE with a Character String"]
[]
["MyDatabaseName",null,null,null,null,null,null,"MyDatabaseName",null,"--OK"]
["USE master; EXEC ('USE [MyDatabaseName]; SELECT TOP 10 CODIGO, NOMBRE FROM SECCIONES;');",null,null,null,null,null,null,"USE [MyDatabaseName]; IF EXISTS(SELECT name FROM sys.tables WHERE name = 't1') DROP TABLE t1; CREATE TABLE t1 (c1 varchar(3), c2 char(3));"]
[]
[]
[]
[]
["Columna1",null,null,null,null,null,null,"Columna1"]
[]
[]
[]
["MyDatabaseName",null," --OK"]
["IF @@OPTIONS & 512 <> 0"]
["PRINT N'This user has SET NOCOUNT turned ON.';"]
["ELSE"]
["PRINT N'This user has SET NOCOUNT turned OFF.';"]
[]
["Columna1"]
[]
[]
[]
["See Also"]
["SET LANGUAGE"]
["Specifies the language environment for the session. The session language determines the  datetime formats"]
["and system messages."]
[]
["DECLARE @Today DATETIME;",null,null,null,null,null,"MyDatabaseName",null,"--OK"]
["SET @Today = '12/5/2007';",null,null,null,null,null,"SELECT @@LANGUAGE;"]
["SET LANGUAGE Italian;"]
["SELECT DATENAME(month, @Today) AS 'Month Name';"]
["SET LANGUAGE us_english;",null,null,null,null,null,"Columna1"]
["SELECT DATENAME(month, @Today) AS 'Month Name' ;",null,null,null,null,null,"Español"]
["GO"]
[]
[]
["See Also"]
["Data Types (Transact-SQL)"]
["syslanguages"]
["sp_helplanguage (Transact-SQL)"]
["SET Statements (Transact-SQL)"]
[]
["MyDatabaseName",null,null,null,null,null,"MyDatabaseName"]
["USE master; RAISERROR (15600,-1,-1, 'mysp_CreateCustomer');",null,null,null,null,null,"RAISERROR (15600,-1,-1, 'mysp_CreateCustomer');"]
[]
[]
[]
[]
["Columna1",null,null,null,null,null,"Columna1"]

{"sheet":"CREATE_TABLE","index":1,"n_rows":208,"n_cols":12,"rows_kept":208,"cut":false,"hidden":false,"merged":[]}
["SQL_Server_documentation_Help.pdf"]
["Tables","pp.3049"]
[]
["MyDatabaseName",null," --OK","MyDatabaseName",null," --OK"]
["USE [MyDatabaseName.mde];",null,null,"USE [MyDatabaseName.mde];",null,null,null,"USE [MyDatabaseName.mde];",null,null,null,"IF EXISTS(SELECT name FROM sys.tables"]
["IF EXISTS(SELECT name FROM sys.tables",null,null,"IF OBJECT_ID ('dbo.t1', 'U') IS NOT NULL",null,null,null,"IF OBJECT_ID ('dbo.t1', 'U') IS NOT NULL",null,null,null,"    WHERE name = 't1')"]
["    WHERE name = 't1')",null,null,"DROP TABLE dbo.t1;",null,null,null,"DROP TABLE dbo.t1;",null,null,null,"  DROP TABLE t1;"]
["  DROP TABLE t1;",null,null,"SELECT CODIGO, NOMBRE",null,null,null,"GO",null,null,null,"GO"]
["CREATE TABLE t1",null,null,"INTO dbo.t1",null,null,null,"-- Create Gloves table.",null,null,null,"CREATE TABLE t1"]
["(",null,null,"FROM dbo.SECCIONES",null,null,null,"SELECT CODIGO, NOMBRE",null,null,null,"("]
["  c1 varchar(3),",null,null,"WHERE CODEMPRESA = '01' AND SECCIONES.ID < 22;",null,null,null,"INTO dbo.t1",null,null,null,"  c1 varchar(3),"]
["  c2 char(3)",null,null,null,null,null,null,"FROM dbo.SECCIONES",null,null,null,"  c2 char(3)"]
[");",null,null,"Columna1",null,null,null,"WHERE SECCIONES.ID < 22;",null,null,null,");"]
[null,null,null,null,null,null,null,"GO",null,null,null,"GO"]
["INSERT INTO t1 VALUES ('2', '2'), ('37', '37'),('597', '597');",null,null,null,null,null,null,null,null,null,null,"INSERT INTO t1 VALUES ('2', '2'), ('37', '37'),('597', '597');"]
[null,null,null,null,null,null,null,null,null,null,null,"GO"]
["SELECT REPLICATE('0', 3 - DATALENGTH(c1)) + c1 AS 'Varchar Column',",null,null,null,null,null,null,null,null,null,null,"SELECT REPLICATE('0', 3 - DATALENGTH(c1)) + c1 AS 'Varchar Column',"]
["    REPLICATE('0', 3 - DATALENGTH(c2)) + c2 AS 'Char Column'",null,null,null,null,null,null,null,null,null,null,"    REPLICATE('0', 3 - DATALENGTH(c2)) + c2 AS 'Char Column'"]
["FROM t1;",null,null,null,null,null,null,null,null,null,null,"FROM t1;"]
[null,null,null,null,null,null,null,null,null,null,null,"GO"]
["Columna1"]
[]
[]
["96 - Subconsulta - Exists y Not Exists",null,null,null,"SQL_Server_DATE_Data_Type.docx",null,null,null,null,"Markus Winand"]
["https://www.tutorialesprogramacionya.com/",null,null,null,"Using DATE to define the table columns example",null,null,null,null,"[SQL Server]"]
[]
["if object_id('detalles') is not null",null,null,null,"CREATE TABLE sales.list_prices (",null,null,null,null,"CREATE TABLE scale_data ("]
["  drop table detalles;",null,null,null,"    product_id INT NOT NULL,",null,null,null,null,"section NUMERIC NOT NULL,"]
["if object_id('facturas') is not null",null,null,null,"    valid_from DATE NOT NULL,",null,null,null,null,"id1 NUMERIC NOT NULL,"]
["  drop table facturas;",null,null,null,"    valid_to DATE NOT NULL,",null,null,null,null,"id2 NUMERIC NOT NULL"]
[null,null,null,null,"    amount DEC (10, 2) NOT NULL,",null,null,null,null,");"]
["create table facturas(",null,null,null,"    PRIMARY KEY (",null,null,null,null,"CREATE INDEX scale_slow ON scale_data(section, id1, id2);"]
["  numero int not null,",null,null,null,"        product_id,"]
["  fecha datetime,",null,null,null,"        valid_from,"]
["  cliente varchar(30),",null,null,null,"        valid_to",null,null,null,null,"-- HeidiSQL"]
["  primary key(numero)",null,null,null,"    ),",null,null,null,null,"--Menu Herramientas / Exportar base de MyDatabaseName a archivo .sql"]
[");",null,null,null,"    FOREIGN KEY (product_id) ",null,null,null,null,"-- Volcando estructura de base de MyDatabaseName para MyDatabaseName2020.mde"]
[null,null,null,null,"      REFERENCES production.products (product_id)",null,null,null,null,"DROP DATABASE IF EXISTS \"MyDatabaseName2020.mde\";"]
["create table detalles(",null,null,null,");",null,null,null,null,"CREATE DATABASE IF NOT EXISTS \"MyDatabaseName2020.mde\";"]
["  numerofactura int not null,",null,null,null,null,null,null,null,null,"USE \"MyDatabaseName2020.mde\";"]
["  numeroitem int not null, ",null,null,null,null,null,null,null,null,"-- Volcando estructura para tabla MyDatabaseName2020.mde.ARTICULOS"]
["  articulo varchar(30),",null,null,null,null,null,null,null,null,"DROP TABLE IF EXISTS \"ARTICULOS\";"]
["  precio decimal(5,2),"]
["  cantidad int,"]
["  primary key(numerofactura,numeroitem),"]
["   constraint FK_detalles_numerofactura"]
["   foreign key (numerofactura)"]
["   references facturas(numero)"]
["   on update cascade"]
["   on delete cascade"]
[");"]
[]
["go"]
[]
["SET DATEFORMAT ymd;"]
[null,null,null,null,"SET DATEFORMAT"]
["insert into facturas values(1200,'2018-01-15','Juan Lopez');"]
["insert into facturas values(1201,'2018-01-15','Luis Torres');"]
["insert into facturas values(1202,'2018-01-15','Ana Garcia');"]
["insert into facturas values(1300,'2018-01-20','Juan Lopez');"]
[]
["insert into detalles values(1200,1,'lapiz',1,100);"]
["insert into detalles values(1200,2,'goma',0.5,150);"]
["insert into detalles values(1201,1,'regla',1.5,80);"]
["insert into detalles values(1201,2,'goma',0.5,200);"]
["insert into detalles values(1201,3,'cuaderno',4,90);"]
["insert into detalles values(1202,1,'lapiz',1,200);"]
["insert into detalles values(1202,2,'escuadra',2,100);"]
["insert into detalles values(1300,1,'lapiz',1,300);"]
[]
["-- Retornar la lista de clientes que compraron el artículo \"lapiz\":"]
["select cliente,numero"]
["  from facturas as f"]
["  where exists"]
["   (select * from detalles as d"]
["     where f.numero=d.numerofactura"]
["     and d.articulo='lapiz');"]
[]
["-- Buscamos los clientes que NO han comprado el artículo \"lapiz\":"]
[" select cliente,numero"]
["  from facturas as f"]
["  where not exists"]
["   (select * from detalles as d"]
["     where f.numero=d.numerofactura"]
["     and d.articulo='lapiz');"]
[]
["[000_Tutorial_Escritura_de_instrucciones_Transact-SQL.docx]"]
[]
["CREATE DATABASE TestData  ",null,null,"MyDatabaseName"," --OK",null,"MyDatabaseName",null,"[BikeStores Sample Database - drop all objects.sql]"]
["GO  ",null,null,"CREATE DATABASE TestData;",null,null,"USE MASTER;  "]
[null,null,null,null,null,null,"DROP DATABASE TestData;",null," --Posiblemente esta sintaxis require unha versión de SQL Server superior á que estou usando (2008 R2)"]
["USE TestData  ",null,null,null,null,null,null,null," --Parece funcionar en SQL Server Management Studio (porque repetindo da erro de obxecto existente). Pero non se ve na lista de bases de MyDatabaseName (tras actualizar vista)"]
["GO  ",null,null,"Columna1",null,null,"Columna1",null," --Ademais a base de MyDatabaseName BikeStores foi creada desde estos arquivos: logo funciona"]
[null,null,null,null,null,null,null,null,"CREATE SCHEMA TestData;"]
["CREATE TABLE dbo.Products  "]
["   (ProductID int PRIMARY KEY NOT NULL,  ",null,null,null,"MyDatabaseName"]
["   ProductName varchar(25) NOT NULL,  ",null,null,null,"TRUNCATE TABLE [MyDatabaseName.mde].dbo.Products;",null,null,null,"TRUNCATE TABLE (Transact-SQL)"]
["   Price money NULL,  ",null,null,null,null,null,null,null,"Removes all rows from a table or specified partitions of a table, without logging the individual row deletions."]
["   ProductDescription varchar(max) NULL)  ",null,null,null,"Columna1",null,null,null,"TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause; however, TRUNCATE TABLE is faster"]
["GO  ",null,null,null,null,null,null,null,"and uses fewer system and transaction log resources."]
[null,null,null,null,null,null,null,null,"If the table contains an identity column, the counter for that column is reset to the seed value defined for the column."]
["-- Standard syntax"]
["INSERT dbo.Products (ProductID, ProductName, Price, ProductDescription) VALUES (1, 'Clamp', 12.48, 'Workbench clamp');"]
["INSERT dbo.Products (ProductID, ProductName, Price, ProductDescription) VALUES (50, 'Screwdriver', 3.17, 'Flat head');"]
["INSERT dbo.Products (ProductID, ProductName, Price, ProductDescription) VALUES (75, 'Tire Bar', NULL, 'Tool for changing tires.');"]
["INSERT dbo.Products (ProductID, ProductName, Price, ProductDescription) VALUES (3000, 'Corchete de 3 mm', 0.52, NULL);"]
[]
["MyDatabaseName",null," --Suficiente así: dbo.Products (xa está especificada a base de MyDatabaseName na cadea de conexión ADO)"]
["CREATE TABLE [MyDatabaseName.mde].dbo.Products",null," --OK"]
["   (ProductID int PRIMARY KEY NOT NULL,  "]
["   ProductName varchar(25) NOT NULL,  "]
["   Price money NULL,  ",null,null,null,"MyDatabaseName",null," -- Skipping the column list, but keeping the values in order"]
["   ProductDescription varchar(max) NULL)",null,null,null,"INSERT dbo.Products VALUES (76, 'Tire Bar', NULL, 'Tool for changing tires.');"]
[]
["Columna1"]
[]
[]
["MyDatabaseName",null,null,null,"Columna1"]
["INSERT dbo.Products (ProductID, ProductName, Price, ProductDescription) VALUES (1, 'Clamp', 12.48, 'Workbench clamp');",null," -- Standard syntax"]
["INSERT dbo.Products (ProductID, ProductName, Price, ProductDescription) VALUES (50, 'Screwdriver', 3.17, 'Flat head');"]
["INSERT dbo.Products (ProductID, ProductName, Price, ProductDescription) VALUES (75, 'Tire Bar', NULL, 'Tool for changing tires.');"]
["INSERT dbo.Products (ProductID, ProductName, Price, ProductDescription) VALUES (3000, 'Corchete de 3 mm', 0.52, NULL);"]
[]
["Columna1"]
[]
[]
["CREATE TABLE (Transact-SQL) IDENTITY (Property)",null,null,null,"pp.24512"]
[]
["USE AdventureWorks2012;"]
["IF OBJECT_ID ('dbo.new_employees', 'U') IS NOT NULL"]
["  DROP TABLE new_employees;"]
["GO"]
["CREATE TABLE new_employees"]
["("]
["  id_num int IDENTITY(1,1) PRIMARY KEY,"]
["  fname varchar (20),"]
["  minit char(1),"]
["  lname varchar(30)"]
[");"]
["INSERT new_employees"]
["  (fname, minit, lname)"]
["VALUES"]
["  ('Karin', 'F', 'Josephs');"]
["INSERT new_employees"]
["  (fname, minit, lname)"]
["VALUES"]
["  ('Pirkko', 'O', 'Koskitalo');"]
[]
["Temporary tables"]
[]
["MyDatabaseName",null,null,null,null,"USE TestDB;",null,null,null,null,null,"SELECT *"]
["CREATE TABLE #TestTempTab",null,null,null,null,"GO",null,null,null,null,null,"INTO #TestTempTab"]
["  (ID int IDENTITY(1,1) PRIMARY KEY,",null,null,null,null,"-- Create a temporary table with the same column declarations",null,null,null,null,null,"FROM [MyDatabaseName.mde].dbo.SECCIONES"]
["  Col1 nchar COLLATE database_default",null,null,null,null,"-- as TestPermTab",null,null,null,null,null,"WHERE CODEMPRESA = '01';"]
[");",null,null,null,null,"CREATE TABLE #TestTempTab (PrimaryKey int PRIMARY KEY, Col1 nchar );",null,null,null,null,null,"USE tempdb;"]
["INSERT dbo.#TestTempTab(Col1) VALUES ('a');",null,null,null,null,"INSERT INTO #TestTempTab",null,null,null,null,null,"SELECT * FROM dbo.#TestTempTab;"]
["INSERT dbo.#TestTempTab(Col1) VALUES ('b');",null,null,null,null,"SELECT * FROM TestPermTab;"]
["USE tempdb;",null,null,null,null,"GO"]
["SELECT * FROM dbo.#TestTempTab;",null,null,null,null,"SELECT * FROM TestPermTab AS a INNER JOIN #TestTempTab on a.Col1 = #TestTempTab.Col1;"]
[]
["Columna1","Columna2"]
[1,"a"]
[2,"b"]
[]
["SQL_Server_documentation_Help.pdf"]
["Copy Columns from One Table to Another (Database Engine)",null,null,null,null,"pp.3071",null,"Specify Computed Columns in a Table"]
[]
["USE AdventureWorks2012;",null,null,null,null,null,null,"CREATE TABLE dbo.Products"]
["GO",null,null,null,null,null,null,"("]
["CREATE TABLE dbo.EmployeeSales",null,null,null,null,null,null,"  ProductID int IDENTITY (1,1) NOT NULL"]
["( BusinessEntityID varchar(11) NOT NULL,",null,null,null,null,null,null,"  , QtyAvailable smallint"]
["  SalesYTD money NOT NULL",null,null,null,null,null,null,"  , UnitPrice money"]
[");",null,null,null,null,null,null,"  , InventoryValue AS QtyAvailable * UnitPrice"]
["GO",null,null,null,null,null,null,")"]
["INSERT INTO dbo.EmployeeSales",null,null,null,null,null,null,";"]
["  SELECT BusinessEntityID, SalesYTD",null,null,null,null,null,null,"-- Insert values into the table."]
["  FROM Sales.SalesPerson;",null,null,null,null,null,null,"INSERT INTO dbo.Products (QtyAvailable, UnitPrice)"]
["GO",null,null,null,null,null,null,"  VALUES (25, 2.00), (10, 1.5)"]
[null,null,null,null,null,null,null,";"]
[null,null,null,null,null,null,null,"-- Display the rows in the table."]
[null,null,null,null,null,null,null,"SELECT ProductID, QtyAvailable, UnitPrice, InventoryValue"]
[null,null,null,null,null,null,null,"FROM dbo.Products"]
[null,null,null,null,null,null,null,";"]
[]
["See Also"]
["Markus Winand",null,"Alan Beaulieu"]
["[MySQL]",null,"[MySQL]"]
["CREATE TABLE demo (",null,"CREATE TABLE department",null,null,null,null,"CREATE TABLE product"]
["id1 NUMERIC",null,"(dept_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,",null,null,null,null,"(product_cd VARCHAR(10) NOT NULL,"]
[", id2 NUMERIC",null,"name VARCHAR(20) NOT NULL,",null,null,null,null,"name VARCHAR(50) NOT NULL,"]
[", id3 NUMERIC",null,"CONSTRAINT pk_department PRIMARY KEY (dept_id) );",null,null,null,null,"product_type_cd VARCHAR (10) NOT NULL,"]
[", val NUMERIC);",null,null,null,null,null,null,"date_offered DATE,"]
["INSERT INTO demo VALUES (1,1,1,1);",null,null,null,null,null,null,"date_retired DATE,"]
["INSERT INTO demo VALUES (2,2,2,2);",null,null,null,null,null,null,"CONSTRAINT fk_product_type_cd FOREIGN KEY (product_type_cd)"]
["CREATE INDEX demo_idx",null,null,null,null,null,null,"REFERENCES product_type (product_type_cd),"]
["ON demo",null,null,null,null,null,null,"CONSTRAINT pk_product PRIMARY KEY (product_cd)"]
["(id1, id2, id3);",null,null,null,null,null,null,");"]
[]
["[Oracle]",null,null,null,null,null,null,"Alternatively,"]
["CREATE TABLE employees (",null,null,null,null,null,null,"you can create the  product table without constraints, and add the primary and foreign"]
["employee_id NUMBER NOT NULL,",null,null,null,null,null,null,"key constraints later via  alter table statements:"]
["first_name VARCHAR2(1000) NOT NULL,"]
["last_name VARCHAR2(1000) NOT NULL,",null,null,null,null,null,null,"ALTER TABLE product"]
["date_of_birth DATE NOT NULL,",null,null,null,null,null,null,"ADD CONSTRAINT pk_product PRIMARY KEY (product_cd);"]
["phone_number VARCHAR2(1000) NOT NULL,"]
["CONSTRAINT employees_pk PRIMARY KEY (employee_id)",null,null,null,null,null,null,"ALTER TABLE product"]
[");",null,null,null,null,null,null,"ADD CONSTRAINT fk_product_type_cd FOREIGN KEY (product_type_cd)"]
[null,null,null,null,null,null,null,"REFERENCES product_type (product_type_cd);"]

{"sheet":"greatest-n-per-group","index":2,"n_rows":332,"n_cols":19,"rows_kept":332,"cut":false,"hidden":false,"merged":[]}
["EXTRAER EL REGISTRO MAS RECIENTE",null,null,null,null,null,null,"DISTINCT (MySQL)"]
[null,null,null,null,null,null,null,"Agrupar y seleccionar el registro con fecha más reciente MySQL"]
["Opcións",null,null,null,null,null,null,"https://es.stackoverflow.com/questions/194394/agrupar-y-seleccionar-el-registro-con-fecha-m%C3%A1s-reciente-mysql"]
["  - SUBCONSULTA NA CLAUSULA WHERE: IN (SELECT MAX ID ... GROUP BY CAMPO)",null,null,null,null,null,null,"Albert Hidalgo, 5 sep. 18 [2,685] [4 up]"]
["   - SELF LEFT JOIN (Bill Karwin)",null,null,null,null,null,null,"SELECT DISTINCT(idEmpleado),FechaMovimiento,Area "]
["  - SUBCONSULTA NA CLAUSULA FROM e JOIN",null,null,null,null,null,null,"FROM bd_secjo.tblmovimientos"]
["  - [MAIS RAPIDA] USAR DISTINCT SOBRE UN UNICO CAMPO",null,null,null,null,null,null,"ORDER BY FechaMovimiento DESC"]
[null,null,null,null,null,null,null,"---"]
[null,null,null,null,null,null,null,"Ruben Hernandez [1078], Esta sin duda es la mejor opción, ya que la sub consulta requiere muchos mas recursos"]
[]
["https://stackoverflow.com/questions/5021693/distinct-for-only-one-column",null,null,null,null,null,null,"https://stackoverflow.com/questions/966176/select-distinct-on-one-column",null,null,null,null,null,null,null,"https://stackoverflow.com/questions/1785634/select-distinct-on-one-column-return-multiple-other-columns-sql-server"]
["Chandu, Feb 16 '11 [76.4k] [202 up] [marked as answer]",null,null,null,null,null,null,"Aaron Alton, Jun 8 '09 [21.5k] [350 up] [marked as answer]",null,null,null,null,null,null,null,"Howie Nov 12 '12"]
[]
["SELECT *",null,null,null,null,null,null,"SELECT  *",null,null,null,null,null,null,null,"WITH DEDUPE AS ("]
["  FROM (",null,null,null,null,null,null,"FROM    (SELECT ID, SKU, Product,",null,null,null,null,null,null,null,"    SELECT  *"]
["                SELECT  ID, ",null,null,null,null,null,null,"                ROW_NUMBER() OVER (PARTITION BY PRODUCT ORDER BY ID) AS RowNumber",null,null,null,null,null,null,null,"          , ROW_NUMBER() OVER ( PARTITION BY what_you_want_for_distinct ORDER BY what_you_want_for_distinct) AS OCCURENCE"]
["                        Email, ",null,null,null,null,null,null,"         FROM   MyTable",null,null,null,null,null,null,null,"    FROM tablename"]
["                        ProductName, ",null,null,null,null,null,null,"         WHERE  SKU LIKE 'FOO%') AS a",null,null,null,null,null,null,null,"    )"]
["                        ProductModel,",null,null,null,null,null,null,"WHERE   a.RowNumber = 1",null,null,null,null,null,null,null,"SELECT  * FROM DEDUPE"]
["                        ROW_NUMBER() OVER(PARTITION BY Email ORDER BY ID DESC) rn",null,null,null,null,null,null,null,null,null,null,null,null,null,null,"WHERE"]
["                    FROM Products",null,null,null,null,null,null,null,null,null,null,null,null,null,null,"OCCURENCE = 1"]
["                   WHERE ProductModel = 2"]
["              ) a"]
["WHERE rn = 1"]
[]
[]
["Ivan, Mar 19 '19 [3,603] [3 up]"]
["Here is a version, basically the same as a couple of the other answers,"]
["but that you can copy paste into your SQL server Management Studio to test,"]
["(and without generating any unwanted tables), thanks to some inline values."]
["---"]
["A great idea for dev work and testing without having to create test tables. Thanks. – luisdev",null,null,null,null,null,null,null,null,null,null,"[AUSENCIA DUN CAMPO ID]"]
[null,null,null,null,null,null,null,null,null,null,null,"SUBCONSULTA CORRELACIONADA NA CLAUSULA WHERE OPERADOR IN, E FUNCION MAX"]
[null,null,null,null,null,null,null,null,null,null,null,"Como seleccionar registros de la fecha mas reciente con MySQL?"]
[null,null,null,null,null,null,"SUBCONSULTA NA CLAUSULA WHERE",null,null,null,null,"https://es.stackoverflow.com/questions/24376/como-seleccionar-registros-de-la-fecha-mas-reciente-con-mysql"]
["MyDatabaseName2",null,null,null,null,null,"MyDatabaseName2",null,null,null,null,"https://es.stackoverflow.com/a/429513"]
[";WITH [cte]([c1],[c2],[c3],[c4]) AS",null,null,null,null,null,";WITH [cte]([ID],[c2],[c3],[c4]) AS",null,null,null,null,"... que son todos los registros nuevos, limpiandote los registros viejos de la tabla según el campo time"]
["(",null,null,null,null,null,"("]
["    SELECT *",null,null,null,null,null,"    SELECT *",null,null,null,null,"MyDatabaseName2"]
["    FROM (",null,null,null,null,null,"    FROM (",null,null,null,null,";WITH [cte]([c2],[c3],[c4]) AS"]
["        VALUES",null,null,null,null,null,"        VALUES",null,null,null,null,"("]
["        (1, 'Adrian', 25,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,"        (1, 'Adrian', 25,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,"    SELECT *"]
["        (2, 'Juan',   23,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,"        (2, 'Juan',   23,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,"    FROM ("]
["        (3, 'Adrian', 22,  CONVERT(DATETIME, '20/08/2020', 103)),",null,null,null,null,null,"        (3, 'Adrian', 22,  CONVERT(DATETIME, '20/08/2020', 103)),",null,null,null,null,"        VALUES"]
["        (4, 'Pedro',  24,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,"        (4, 'Pedro',  24,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,"        ('Adrian', 25,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (5, 'Agus',   20,  CONVERT(DATETIME, '01/08/2020', 103))",null,null,null,null,null,"        (5, 'Agus',   20,  CONVERT(DATETIME, '01/08/2020', 103))",null,null,null,null,"        ('Juan',   23,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["    )",null,null,null,null,null,"    )",null,null,null,null,"        ('Adrian', 22,  CONVERT(DATETIME, '20/08/2020', 103)),"]
["    AS [cte]([c1],[c2],[c3],[c4])",null,null,null,null,null,"    AS [cte]([ID],[c2],[c3],[c4])",null,null,null,null,"        ('Pedro',  24,  CONVERT(DATETIME, '01/08/2020', 103)),"]
[")",null,null,null,null,null,")",null,null,null,null,"        ('Agus',   20,  CONVERT(DATETIME, '01/08/2020', 103))"]
["SELECT *",null,null,null,null,null,"SELECT * FROM [cte] WHERE [ID] IN ",null,null,null,null,"    )"]
["  FROM (SELECT *,",null,null,null,null,null,"(",null,null,null,null,"    AS [cte]([c2],[c3],[c4])"]
["               ROW_NUMBER() OVER(PARTITION BY c2 ORDER BY c4 DESC) rn",null,null,null,null,null,"    SELECT MAX([ID]) ",null,null,null,null,")"]
["        FROM cte",null,null,null,null,null,"    FROM [cte] ",null,null,null,null,"SELECT *"]
["        ) a",null,null,null,null,null,"    GROUP BY [c2]",null,null,null,null,"FROM cte AS subset1"]
["WHERE a.rn = 1",null,null,null,null,null,")",null,null,null,null,"WHERE c4 IN (SELECT MAX(c4) FROM cte AS subset2 WHERE subset1.c2 = subset2.c2)"]
["ORDER BY c2;",null,null,null,null,null,"ORDER BY c2;",null,null,null,null,"ORDER BY c2;"]
[]
["Columna1","Columna2","Columna3","Columna4","Columna5",null,"Columna1","Columna2","Columna3","Columna4",null,"Columna1","Columna2","Columna3"]
[3,"Adrian",22,"2020-08-20",1,null,3,"Adrian",22,"2020-08-20",null,"Adrian",22,"2020-08-20"]
[5,"Agus",20,"2020-08-01",1,null,5,"Agus",20,"2020-08-01",null,"Agus",20,"2020-08-01"]
[2,"Juan",23,"2020-08-01",1,null,2,"Juan",23,"2020-08-01",null,"Juan",23,"2020-08-01"]
[4,"Pedro",24,"2020-08-01",1,null,4,"Pedro",24,"2020-08-01",null,"Pedro",24,"2020-08-01"]
[]
["VER:",null,null,null,null,null,null,null,null,null,null,"SUBCONSULTA CORRELACIONADAS NA CLAUSULA WHERE (OPERADOR ALL)"]
["FIRST_VALUE (Transact-SQL)",null,null,null,null,null,null,null,null,null,null,"Subconsultas - Manual de SQL (Oracle SQL)"]
["FIRST_VALUE_SQL_Server.docx",null,null,null,null,null,null,null,null,null,null,"Jorge Sánchez"]
["Get_Row_with_Greatest_Value_per_Group_&_Handling_Duplicate_Rows.docx",null,null,null,null,null,null,null,null,null,null,"https://jorgesanchez.net/"]
["SQL_PARTITION_BY_Clause_overview_Rajendra_Gupta.docx",null,null,null,null,null,null,null,null,null,null,"[9.2.3] consultas correlacionadas"]
[null,null,null,null,null,null,null,null,null,null,null,"SELECT l.nombre, poblacion"]
[null,null,null,null,null,null,null,null,null,null,null,"FROM localidades l"]
[null,null,null,null,null,null,null,null,null,null,null,"WHERE poblacion >= ALL("]
[null,null,null,null,null,null,null,null,null,null,null,"  SELECT poblacion"]
[null,null,null,null,null,null,null,null,null,null,null,"  FROM localidades l2"]
[null,null,null,null,null,null,null,null,null,null,null,"  WHERE l2.n_provincia = l.n_provincia"]
[null,null,null,null,null,null,null,null,null,null,null,") a"]
[]
["SELF JOIN",null,null,null,null,null,null,null,null,null,null,"MyDatabaseName2"]
["Bill Karwin [441k] [154 up]",null,null,null,null,null,null,null,null,null,null,";WITH [cte]([c2],[c3],[c4]) AS"]
["[AUTOR DO LIBRO SQL_Antipatterns]  ",null,null,null,null,null,null,null,null,null,null,"("]
["https://stackoverflow.com/a/8749095/684229",null,null,null,null,null,null,null,null,null,null,"    SELECT *"]
["So you want to get the row with the highest OrderField per group? I'd do it this way:",null,null,null,null,null,null,null,null,null,null,"    FROM ("]
["SELECT t1.*",null,null,null,null,null,null,null,null,null,null,"        VALUES"]
["FROM `Table` AS t1",null,null,null,null,null,null,null,null,null,null,"        ('Adrian', 25,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["LEFT OUTER JOIN `Table` AS t2",null,null,null,null,null,null,null,null,null,null,"        ('Juan',   23,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["  ON t1.GroupId = t2.GroupId AND t1.OrderField < t2.OrderField",null,null,null,null,null,null,null,null,null,null,"        ('Adrian', 22,  CONVERT(DATETIME, '20/08/2020', 103)),"]
["WHERE t2.GroupId IS NULL",null,null,null,null,null,null,null,null,null,null,"        ('Pedro',  24,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["ORDER BY t1.OrderField; // not needed! (note by Tomas)",null,null,null,null,null,null,null,null,null,null,"        ('Agus',   20,  CONVERT(DATETIME, '01/08/2020', 103))"]
["In other words, return the row t1 for which no other row t2 exists with the same GroupId and a greater OrderField.",null,null,null,null,null,null,null,null,null,null,"    )"]
["When t2.* is NULL, it means the left outer join found no such match, and therefore t1 has the greatest value of OrderField in the group.",null,null,null,null,null,null,null,null,null,null,"    AS [cte]([c2],[c3],[c4])"]
[null,null,null,null,null,null,null,null,null,null,null,")"]
["MyDatabaseName2",null,null,null,null,null,null,null,null,null,null,"SELECT *"]
[";WITH [cte]([c1],[c2],[c3],[c4]) AS",null,null,null,null,null,null,null,null,null,null,"FROM cte AS subset1"]
["(",null,null,null,null,null,null,null,null,null,null,"WHERE c4 >= ALL("]
["    SELECT *",null,null,null,null,null,null,null,null,null,null,"  SELECT c4"]
["    FROM (",null,null,null,null,null,null,null,null,null,null,"  FROM cte subset2"]
["        VALUES",null,null,null,null,null,null,null,null,null,null,"  WHERE subset1.c2 = subset2.c2"]
["        (1, 'Adrian', 25,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,"  )"]
["        (2, 'Juan',   23,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,"ORDER BY c2;"]
["        (3, 'Adrian', 22,  CONVERT(DATETIME, '20/08/2020', 103)),"]
["        (4, 'Pedro',  24,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,"Columna1","Columna2","Columna3"]
["        (5, 'Agus',   20,  CONVERT(DATETIME, '01/08/2020', 103))",null,null,null,null,null,null,null,null,null,null,"Adrian",22,"2020-08-20"]
["    )",null,null,null,null,null,null,null,null,null,null,"Agus",20,"2020-08-01"]
["    AS [cte]([c1],[c2],[c3],[c4])",null,null,null,null,null,null,null,null,null,null,"Juan",23,"2020-08-01"]
[")",null,null,null,null,null,null,null,null,null,null,"Pedro",24,"2020-08-01"]
["SELECT subset1.*"]
["FROM cte AS subset1",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"SUBCONSULTA NA CLAUSULA FROM e JOIN"]
["LEFT OUTER JOIN cte AS subset2",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Subconsultas - Manual de SQL (Oracle SQL)"]
["  ON subset1.c2 = subset2.c2 AND subset1.c4 < subset2.c4",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Jorge Sánchez"]
["WHERE subset2.c2 IS NULL",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"https://jorgesanchez.net/"]
["ORDER BY subset1.c2;",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"esta consulta nos muestra el tipo y modelo de las piezas que tiene el precio de venta más alto"]
[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"A esta técnica se le llama usar vistas en línea (en inglés inline views)"]
["Columna1","Columna2","Columna3","Columna4",null,null,null,null,null,null,null,null,null,null,null,null,"SELECT tipo,modelo,precio_venta"]
[3,"Adrian",22,"2020-08-20",null,null,null,null,null,null,null,null,null,null,null,null,"FROM piezas P1"]
[5,"Agus",20,"2020-08-01",null,null,null,null,null,null,null,null,null,null,null,null,"JOIN ("]
[2,"Juan",23,"2020-08-01",null,null,null,null,null,null,null,null,null,null,null,null,"  SELECT MAX(precio_venta) max_precio_venta"]
[4,"Pedro",24,"2020-08-01",null,null,null,null,null,null,null,null,null,null,null,null,"  FROM piezas"]
[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,") P2 ON P1.precio_venta=P2.max_precio_venta;"]
["ULTIMA ANALITICA PARA CADA ID DE AGRUPACION"]
[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"MyDatabaseName2"]
["MyDatabaseName2",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,";WITH [cte]([c2],[c3],[c4]) AS"]
[";WITH [cte]([ReferenciaLinea],[FechaEntradaTanque]) AS",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"("]
["(",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"    SELECT *"]
["    SELECT *",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"    FROM ("]
["    FROM (",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"        VALUES"]
["        VALUES",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"        ('Adrian', 25,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (1, CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"        ('Juan',   23,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (1, CONVERT(DATETIME, '15/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"        ('Adrian', 22,  CONVERT(DATETIME, '20/08/2020', 103)),"]
["        (1, CONVERT(DATETIME, '31/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"        ('Pedro',  24,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (2, CONVERT(DATETIME, '02/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"        ('Agus',   20,  CONVERT(DATETIME, '01/08/2020', 103))"]
["        (2, CONVERT(DATETIME, '06/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"    )"]
["        (2, CONVERT(DATETIME, '10/08/2020', 103))",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"    AS [cte]([c2],[c3],[c4])"]
["    )",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,")"]
["    AS [cte]([ReferenciaLinea],[FechaEntradaTanque])",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"SELECT subset1.c2, subset1.c3, subset1.c4"]
["),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"FROM cte AS subset1"]
["[cte2]([ReferenciaLinea],[FechaAnalitica]) AS",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"INNER JOIN ("]
["(",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"  SELECT c2, MAX(c4) max_c4"]
["    SELECT *",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"  FROM cte"]
["    FROM (",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"  GROUP BY c2"]
["        VALUES",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,") subset2 ON subset1.c4 = subset2.max_c4 AND subset1.c2 = subset2.c2"]
["        (1, CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"ORDER BY subset1.c2;"]
["        (1, CONVERT(DATETIME, '05/08/2020', 103)),"]
["        (1, CONVERT(DATETIME, '10/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Columna1","Columna2","Columna3"]
["        (1, CONVERT(DATETIME, '15/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Adrian",22,"2020-08-20"]
["        (1, CONVERT(DATETIME, '01/09/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Agus",20,"2020-08-01"]
["        (2, CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Juan",23,"2020-08-01"]
["        (2, CONVERT(DATETIME, '05/08/2020', 103)),",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Pedro",24,"2020-08-01"]
["        (2, CONVERT(DATETIME, '07/08/2020', 103)),"]
["        (2, CONVERT(DATETIME, '10/08/2020', 103))"]
["    )"]
["    AS [cte2]([ReferenciaLinea],[FechaAnalitica])"]
[")"]
["SELECT a.ReferenciaLinea, a.FechaEntradaTanque, a.FechaAnalitica"]
["  FROM (SELECT cte.ReferenciaLinea, cte.FechaEntradaTanque, cte2.FechaAnalitica,"]
["               ROW_NUMBER() OVER(PARTITION BY cte.ReferenciaLinea, cte.FechaEntradaTanque ORDER BY cte2.FechaAnalitica DESC) rn"]
["        FROM cte LEFT JOIN cte2 ON cte.ReferenciaLinea = cte2.ReferenciaLinea"]
["        WHERE NOT cte2.FechaAnalitica > cte.FechaEntradaTanque"]
["        ) a"]
["WHERE a.rn = 1"]
["ORDER BY a.ReferenciaLinea;"]
[]
["ID_LAB","FechaEntradaTanque","FechaAnalitica"]
[1,"2020-08-01","2020-08-01"]
[1,"2020-08-15","2020-08-15"]
[1,"2020-08-31","2020-08-15"]
[2,"2020-08-02","2020-08-01"]
[2,"2020-08-06","2020-08-05"]
[2,"2020-08-10","2020-08-10"]
[]
["Markus Winand"]
["https://modern-sql.com/"]
["with — Organize Complex Queries"]
["Each of these queries can refer to the query names previously defined within the same with clause"]
["WITH query_name1 AS ("]
["     SELECT ..."]
["     )"]
["   , query_name2 AS ("]
["     SELECT ..."]
["       FROM query_name1"]
["        ..."]
["     )"]
["SELECT ..."]
[]
["MyDatabaseName2"]
[";WITH [cte]([c1],[c2],[c3],[c4]) AS"]
["("]
["    SELECT *"]
["    FROM ("]
["        VALUES"]
["        (1, 'Adrian', 25,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (2, 'Juan',   23,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (3, 'Adrian', 22,  CONVERT(DATETIME, '20/08/2020', 103)),"]
["        (4, 'Pedro',  24,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (5, 'Agus',   20,  CONVERT(DATETIME, '01/08/2020', 103))"]
["    )"]
["    AS [cte]([c1],[c2],[c3],[c4])"]
["),"]
["[cte2]([c1],[c2],[c3],[c4]) AS"]
["("]
["    SELECT *"]
["    FROM cte"]
["    WHERE c2 = 'Adrian'"]
[")"]
["SELECT cte2.*"]
["FROM cte2"]
["ORDER BY cte2.c2; --example comment"]
[]
["Columna1","Columna2","Columna3","Columna4"]
[1,"Adrian",25,"2020-08-01"]
[3,"Adrian",22,"2020-08-20"]
[]
["Sintaxis algo simplificada",null,null,null,null,null,null,"markus.winand@winand.at"]
[null,null,null,null,null,null,null,"Hi!"]
["MyDatabaseName2"]
[";WITH cte AS",null,null,null,null,null,null,"Looking at this:"]
["  (",null,null,null,null,null,null,"https://modern-sql.com/feature/values#compatibility"]
["    SELECT *"]
["    FROM (",null,null,null,null,null,null,"There is says that \"With t as (values …)” doesn’t work in SQL Server (which is right, I think)."]
["        VALUES",null,null,null,null,null,null,"Because your examples put the VALUES inside a FROM clause, which is marked as OK in the same charge (\"From|Join (values …) t”)."]
["        (1, 'Adrian', 25,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (2, 'Juan',   23,  CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,null,null,null,"I haven’t checked every example you sent me, but on the first sight it seems to be a misunderstanding"]
["        (3, 'Adrian', 22,  CONVERT(DATETIME, '20/08/2020', 103)),",null,null,null,null,null,null,"The X for \"With t as (values …)” means that this does not work:"]
["        (4, 'Pedro',  24,  CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (5, 'Agus',   20,  CONVERT(DATETIME, '01/08/2020', 103))",null,null,null,null,null,null,"WITH cte AS ("]
["    ) cte (c1, c2, c3, c4)",null,null,null,null,null,null,"   VALUES (1)"]
["  ),",null,null,null,null,null,null,")"]
["cte2 AS",null,null,null,null,null,null,"SELECT * FROM cte;"]
["("]
["    SELECT *"]
["    FROM cte"]
["    WHERE c2 = 'Adrian'"]
[")"]
["SELECT cte2.*"]
["FROM cte2"]
["ORDER BY cte2.c2; --example comment"]
[]
["Columna1","Columna2","Columna3","Columna4"]
[1,"Adrian",25,"2020-08-01"]
[3,"Adrian",22,"2020-08-20"]
[]
[]
["Keeping it simple and how to do multiple CTE in a query"]
["https://stackoverflow.com/questions/2140750/keeping-it-simple-and-how-to-do-multiple-cte-in-a-query"]
["Quassnoi, Jan 26 '10 [385k] [357 up] [marked as answer]"]
["MyDatabaseName2"]
[";WITH    cte1 AS"]
["        ("]
["        SELECT  1 AS id"]
["        ),"]
["        cte2 AS"]
["        ("]
["        SELECT  2 AS id"]
["        )"]
["SELECT  *"]
["FROM    cte1"]
["UNION ALL"]
["SELECT  *"]
["FROM    cte2"]
["UNION ALL"]
["SELECT  *"]
["FROM    cte1"]
[]
["Columna1"]
[1]
[2]
[1]
[null,null,null,null,"https://stackoverflow.com/questions/6201253/how-to-get-the-last-record-per-group-in-sql"]
[null,null,null,null,"tartakynov [9 up]"]
["LAST_VALUE",null,null,null,"https://stackoverflow.com/a/21844184/6406135"]
[null,null,null,null,"Since SQL Server 2012 you can simply: [usar FIRST_VALUE ...]"]
["MyDatabaseName2"]
[";WITH cte AS",null,null,null,"SQL_Server_documentation_Help.pdf"]
["(",null,null,null,"Using LAST_VALUE over partitions (p. 21933)"]
["    SELECT *",null,null,null,"The following example returns the hire date of the last employee in each department for the given salary (Rate)"]
["    FROM (",null,null,null,"The PARTITION BY clause partitions the employees by department ..."]
["        VALUES",null,null,null,"USE AdventureWorks2012;"]
["        (1, CONVERT(DATETIME, '01/08/2020', 103)),",null,null,null,"GO"]
["        (1, CONVERT(DATETIME, '15/08/2020', 103)),",null,null,null,"SELECT Department, LastName, Rate, HireDate,"]
["        (1, CONVERT(DATETIME, '31/08/2020', 103)),",null,null,null,"LAST_VALUE(HireDate) OVER (PARTITION BY Department ORDER BY Rate) AS LastValue"]
["        (2, CONVERT(DATETIME, '02/08/2020', 103)),",null,null,null,"FROM HumanResources.vEmployeeDepartmentHistory AS edh"]
["        (2, CONVERT(DATETIME, '06/08/2020', 103)),",null,null,null,"INNER JOIN HumanResources.EmployeePayHistory AS eph"]
["        (2, CONVERT(DATETIME, '10/08/2020', 103))",null,null,null,"ON eph.BusinessEntityID = edh.BusinessEntityID"]
["    ) cte (ReferenciaLinea, FechaEntradaTanque)",null,null,null,"INNER JOIN HumanResources.Employee AS e"]
["),",null,null,null,"ON e.BusinessEntityID = edh.BusinessEntityID"]
["cte2 AS",null,null,null,"WHERE Department IN (N'Information Services',N'Document Control');"]
["("]
["    SELECT *"]
["    FROM ("]
["        VALUES"]
["        (1, CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (1, CONVERT(DATETIME, '05/08/2020', 103)),"]
["        (1, CONVERT(DATETIME, '10/08/2020', 103)),"]
["        (1, CONVERT(DATETIME, '15/08/2020', 103)),"]
["        (1, CONVERT(DATETIME, '01/09/2020', 103)),"]
["        (2, CONVERT(DATETIME, '01/08/2020', 103)),"]
["        (2, CONVERT(DATETIME, '05/08/2020', 103)),"]
["        (2, CONVERT(DATETIME, '07/08/2020', 103)),"]
["        (2, CONVERT(DATETIME, '10/08/2020', 103))"]
["    )"]
["    AS cte2 (ReferenciaLinea, FechaAnalitica)"]
[")"]
["SELECT a.ReferenciaLinea, a.FechaEntradaTanque, a.LastValue"]
["  FROM (SELECT cte.ReferenciaLinea, cte.FechaEntradaTanque,"]
["            LAST_VALUE(cte2.FechaAnalitica) OVER (PARTITION BY cte.ReferenciaLinea, cte.FechaEntradaTanque ORDER BY cte2.FechaAnalitica) AS LastValue"]
["        FROM cte LEFT JOIN cte2 ON cte.ReferenciaLinea = cte2.ReferenciaLinea"]
["        WHERE NOT cte2.FechaAnalitica > cte.FechaEntradaTanque"]
["        ) a"]
["ORDER BY a.ReferenciaLinea;"]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
["Columna1","Columna2","Columna3","Columna4"]
[]
[]
[]
[]
[]
[]
[]
["MyDatabaseName2"]
["SELECT CONVERT (NVARCHAR(10), GETDATE(), 103)",null,null,"SELECT CAST(GETDATE() AS NVARCHAR(30))"]
[null,null,null,"SELECT CONVERT (NVARCHAR(30), GETDATE(), 103)"]
[]
["Columna1"]
["01/08/2021"]

{"sheet":"CAST_CONVERT","index":3,"n_rows":113,"n_cols":7,"rows_kept":113,"cut":false,"hidden":false,"merged":[]}
["SQL_Server_documentation_Help.pdf",null,null,null,"Ver: Convert_a_string_to_int_using_sql_query.docx"]
["Conversion Functions"]
["data type casting and conversion"]
[null,null,null,"completa con espacios",null,null,"max pos"]
[]
["MyDatabaseName",null,null,"MyDatabaseName",null,null,"MyDatabaseName"]
["SELECT CAST(10.3496847 AS money);",null,null,"SELECT CAST(15000 AS char(5));",null,null,"SELECT CAST(3374.99 AS VARCHAR(12));"]
[]
[]
["Columna1",null,null,"Columna1",null,null,"Columna1"]
[10.3497,null,null,"15000 ",null,null,"3374.99"]
[]
["Using CAST with the LIKE clause"]
["This example converts the  money column  SalesYTD values to data type  int , and then to data type char(20) , so"]
["that the  LIKE clause can use it."]
[]
["USE AdventureWorks2012;"]
["GO"]
["SELECT p.FirstName, p.LastName, s.SalesYTD, s.BusinessEntityID"]
["FROM Person.Person AS p"]
["JOIN Sales.SalesPerson AS s"]
["ON p.BusinessEntityID = s.BusinessEntityID"]
["WHERE CAST(CAST(s.SalesYTD AS INT) AS char(20)) LIKE '2%';"]
["GO"]
[]
["Using CAST and CONVERT with datetime data"]
[]
["Starting with  GETDATE() values, this example displays the current date and time, uses  CAST to change the"]
["current date and time to a character data type, and then uses  CONVERT to display the date and time in the"]
["ISO 8601 format."]
[]
["SELECT"]
["GETDATE() AS UnconvertedDateTime,"]
["CAST(GETDATE() AS NVARCHAR(30)) AS UsingCast,"]
["CONVERT(nvarchar(30), GETDATE(), 126) AS UsingConvertTo_ISO8601 ;"]
["GO"]
[]
["This example is approximately the opposite of the previous example. This example displays a date and time as"]
["character data, uses  CAST to change the character data to the  datetime data type, and then uses  CONVERT to"]
["change the character data to the  datetime data type."]
[]
["SELECT"]
["'2006-04-25T15:50:59.997' AS UnconvertedText,"]
["CAST('2006-04-25T15:50:59.997' AS datetime) AS UsingCast,"]
["CONVERT(datetime, '2006-04-25T15:50:59.997', 126) AS UsingConvertFrom_ISO8601 ;"]
["GO"]
[]
["Converting date and time data types"]
[]
["This example shows the conversion of date, time, and datetime data types."]
[]
["DECLARE @d1 DATE, @t1 TIME, @dt1 DATETIME;"]
["SET @d1 = GETDATE();"]
["SET @t1 = GETDATE();"]
["SET @dt1 = GETDATE();"]
["SET @d1 = GETDATE();"]
["-- When converting date to datetime the minutes portion becomes zero."]
["SELECT @d1 AS [DATE], CAST (@d1 AS DATETIME) AS [date as datetime];"]
["-- When converting time to datetime the date portion becomes zero"]
["-- which converts to January 1, 1900."]
["SELECT @t1 AS [TIME], CAST (@t1 AS DATETIME) AS [time as datetime];"]
["-- When converting datetime to date or time non-applicable portion is dropped."]
["SELECT @dt1 AS [DATETIME], CAST (@dt1 AS DATE) AS [datetime as date],"]
["CAST (@dt1 AS TIME) AS [datetime as time];"]
[]
[]
["Using CONVERT with datetime data in different formats",null,null,null,null,"pp.21993"]
["Starting with  GETDATE() values, this example uses  CONVERT to display of all the date and time styles in section"]
["Date and Time styles of this article"]
[]
["EXAMPLE QUERY",null,null,null,"SAMPLE RESULT"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 0)",null,null,null,"Aug 23 2019 1:39PM"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 3)",null,null,null,"23/08/19"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 4)",null,null,null,"23.08.19"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 5)",null,null,null,"23-08-19"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 6)",null,null,null,"23 Aug 19"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 7)",null,null,null,"Aug 23, 19"]
["..."]
["SELECT CONVERT(NVARCHAR, GETDATE(), 20)",null,null,null,"2019-08-23 13:39:17"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 22)",null,null,null,"08/23/19 1:39:17 PM"]
["SELECT CONVERT(NVARCHAR, GETDATE(), 23)",null,null,null,"2019-08-23"]
["SELECT CONVERT(NVARCHAR, GETDATE(), 102)",null,null,null,"2019.08.23"]
["SELECT CONVERT(NVARCHAR, GETDATE(), 103)",null,null,null,"23/08/2019"]
["SELECT CONVERT(NVARCHAR, GETDATE(), 104)",null,null,null,"23.08.2019"]
["SELECT CONVERT(NVARCHAR, GETDATE(), 105)",null,null,null,"23-08-2019"]
["SELECT CONVERT(NVARCHAR, GETDATE(), 106)",null,null,null,"23 Aug 2019"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 111)",null,null,null,"2019/08/23"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 112)",null,null,null,"20190823"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 126)",null,null,null,"2019-08-23T13:39:17.090"]
[]
["SELECT CONVERT(NVARCHAR, GETDATE(), 131)",null,null,null,"22/12/1440 1:39:17.090PM"]
[]
["Effects of data type precedence in allowed conversions"]
["The following example defines a variable of type VARCHAR, assigns an integer value to the variable, then selects"]
["a concatenation of the variable with a string."]
[]
["DECLARE @string VARCHAR(10);"]
["SET @string = 1;"]
["SELECT @string + ' is a string.' AS Result"]
[]
["The int value of 1 was converted to a VARCHAR."]
[]
["Ver: PARSE (Transact-SQL)"]

{"sheet":"MATH","index":4,"n_rows":40,"n_cols":9,"rows_kept":40,"cut":false,"hidden":false,"merged":[]}
["SQL_Server_documentation_Help.pdf"]
["Mathematical Functions (Transact-SQL)"]
[]
["The following scalar functions perform a calculation, usually based on input values that are provided as"]
["arguments, and return a numeric value:"]
[]
["CEILING (Transact-SQL)"]
["This function returns the smallest integer greater than, or equal to, the specified numeric expression."]
[]
["MyDatabaseName",null,null,null,null,null,"MyDatabaseName"]
["SELECT CEILING($123.45), CEILING($-123.45), CEILING($0.0);",null,null,null,null,null,"SELECT FLOOR(123.45), FLOOR(-123.45), FLOOR($123.45);"]
[]
[]
["Columna1","Columna2","Columna3",null,null,null,"Columna1","Columna2","Columna3"]
[124,-123,0,null,null,null,123,-124,123]
[]
[]
["Arithmetic Operators (Transact-SQL)"]
[]
["Arithmetic operators run mathematical operations on two expressions of one or more data types. They're run"]
["from the numeric data type category. For more information about data type categories, see Transact-SQL Syntax Conventions."]
[]
["% (Modulus) (Transact-SQL)"]
["Returns the remainder of one number divided by another."]
[]
["The following example divides the number 38 by 5. This results in 7 as the integer portion of the result and"]
["demonstrates how modulo returns the remainder of 3."]
[]
["MyDatabaseName",null,null,null,"MyDatabaseName"]
["SELECT 38 / 5 AS Integer, 38 % 5 AS Remainder;",null,null,null,"SELECT 155000 % 1000 AS Remainder;"]
[]
[]
["Columna1","Columna2",null,null,"Columna1"]
[7,3,null,null,0]
[]
[]
["See Also"]
["Mathematical Functions (Transact-SQL)"]
["Data Types (Transact-SQL)"]
["Expressions (Transact-SQL)"]

{"sheet":"DATE","index":5,"n_rows":221,"n_cols":12,"rows_kept":221,"cut":false,"hidden":false,"merged":[]}
["SQL_Server_documentation_Help.pdf"]
["Date and Time Data Types and Functions (Transact-SQL)"]
[]
["Functions That Return Date and Time Parts"]
["DATEPART ( datepart,  date )",null,null,null,"pp.22133"]
["Returns an integer representing the specified datepart of the specified date"]
[]
["DAY ( date )"]
["MONTH ( date )"]
["YEAR ( date )"]
[]
["Functions That Return Date and Time Values from Their Parts"]
["DATEFROMPARTS (year ,  month ,  day)"]
["Returns a date value for the specified year, month, and day."]
[]
["DATETIME2FROMPARTS ( year , month , day , hour , minute , seconds , fractions , precision )"]
["Returns a datetime2 value for the specified date and time, with the specified precision."]
[]
["DATETIMEFROMPARTS ( year , month , day , hour , minute , seconds , milliseconds )"]
["Returns a datetime value for the specified date and time."]
[]
["DATETIMEOFFSETFROMPARTS ( year , month , day , hour , minute , seconds , fractions , hour_offset , minute_offset , precision )"]
["Returns a datetimeoffset value for the specified date and time, with the specified offsets and precision."]
[]
["SMALLDATETIMEFROMPARTS ( year , month , day , hour , minute )"]
["Returns a smalldatetime value for the specified date and time."]
[]
["TIMEFROMPARTS ( hour ,  minute , seconds , fractions , precision )"]
["Returns a time value for the specified time, with the specified precision."]
[]
["Functions That Return Date and Time Difference Values"]
["DATEDIFF ( datepart , startdate ,  enddate )"]
["Returns the number of date or time datepart boundaries, crossed between two specified dates."]
[]
["Functions That Modify Date and Time Values"]
["DATEADD ( datepart , number ,  date ) "]
["Returns a new datetime value by adding an interval to the specified datepart of the specified  date"]
[]
["DATEADD ( datepart , number ,  date ) "]
["Returns the last day of the month containing the specified date, with an optional offset."]
[]
["Functions That Validate Date and Time Values"]
["ISDATE ( expression ) "]
["Determines whether a datetime or smalldatetime input expression has a valid date or time value."]
["ISDATE is deterministic only used with the CONVERT function, when the CONVERT style parameter is specified, and when style is not equal to 0, 100, 9, or 109."]
[]
["Date and time-related topics"]
["FORMAT","--REQUIRE VERSION SUPERIOR A 2008"]
["Returns a value formatted with the specified format and optional culture."]
["Use the FORMAT function for locale-aware formatting of date/time and number values as strings."]
[]
["CAST and CONVERT (Transact-SQL) "]
["Provides information about the conversion of date and time values to and from string literals, and other date and time formats."]
[]
["Write International Transact-SQL Statements"]
["Provides guidelines for portability of databases and database applications that use Transact-SQL statements from one language to another, or that support multiple languages."]
[]
["ODBC Scalar Functions (Transact-SQL)"]
["Provides information about ODBC scalar functions available for use in Transact-SQL statements."]
["This includes ODBC date and time functions."]
[]
["AT TIME ZONE (Transact-SQL) "]
["Provides time zone conversion."]
[]
["See Also"]
["Functions"]
["Data Types (Transact-SQL)"]
[]
["ONTE"]
["date >= DATEADD(day, -1, convert(date, GETDATE()))"]
[]
["A partir de SQL Server 2014",null,null,null,"SQL Server 2008"]
[]
["MyDatabaseName",null,null,null,"MyDatabaseName",null,null,"MyDatabaseName",null,null,null,"MyDatabaseName"]
["SELECT DATEFROMPARTS ( 2010, 12, 31 ) AS Result;",null,null,null,"SELECT CONVERT(DATETIME, GETDATE());",null,null,"SELECT CONVERT(DATETIME, '31/10/2021', 103);",null,null,null,"SELECT CONVERT(DATETIME, '2021/10/31', 20);"]
[]
[]
["Columna1",null,null,null,"Columna1",null,null,"Columna1",null,null,null,"Columna1"]
[null,null,null,null,"2021-10-31T12:03:17.490",null,null,"2021-10-31",null,null,null,"2021-10-31"]
[]
[null,null,null,null,"MyDatabaseName"]
[null,null,null,null,"SELECT CAST('2021-10-31T15:50:59.997' AS datetime) AS UsingCast;"]
[]
[]
[null,null,null,null,"Columna1"]
[null,null,null,null,"2021-10-31T15:50:59.997"]
[]
[null,null,null,null,"MyDatabaseName"]
[null,null,null,null,"SELECT CONVERT(datetime, '2021-10-31T15:50:59.997', 126) AS UsingConvertFrom_ISO8601"]
[]
[]
[null,null,null,null,"Columna1"]
[null,null,null,null,"2021-10-31T15:50:59.997"]
[]
[null,null,null,null,"MyDatabaseName"]
[null,null,null,null,"DECLARE @d1 DATE, @t1 TIME, @dt1 DATETIME;"]
[null,null,null,null,"SET @d1 = GETDATE();",null,"-- When converting date to datetime the minutes portion becomes zero."]
[null,null,null,null,"SET @t1 = GETDATE();",null,"-- When converting time to datetime the date portion becomes zero"]
[null,null,null,null,"SET @dt1 = GETDATE();",null,"-- which converts to January 1, 1900."]
[null,null,null,null,"SET @d1 = GETDATE();",null,"-- When converting datetime to date or time non-applicable portion is dropped."]
[null,null,null,null,"SELECT @d1 AS [DATE], CAST (@d1 AS DATETIME) AS [date as datetime], CAST (@t1 AS DATETIME) AS [time as datetime], CAST (@dt1 AS DATE) AS [datetime as date], CAST (@dt1 AS TIME) AS [datetime as time];"]
[]
[null,null,null,null,"[DATE]","[date as datetime]","[time as datetime]","[datetime as date]","[datetime as time]"]
[null,null,null,null,"2021-10-31","2021-10-31","1900-01-02T11:59:31.803","2021-10-31","11:59:31.8030000"]
[]
[null,null,null,null,null,null,"1900-01-01 11:59:55.750"]
[null,null,null,null,null,null,"En SQL Server Management Studio"]
[]
["DATEADD"]
[]
["MyDatabaseName",null,"--OK",null,"MyDatabaseName"]
["SELECT DATEADD(month, 1, '20060830');",null,null,null,"SELECT DATEADD(month, 1, '20060831');"]
[]
[]
["Columna1",null,null,null,"Columna1"]
["2006-09-30",null,null,null,"2006-09-30"]
[]
[]
["Incrementing datepart by an interval of 1",null,null,null,null,null,"Specifying user-defined variables as number and date"]
[]
[]
["MyDatabaseName",null,null,null,null,null,"MyDatabaseName"]
["DECLARE @datetime2 datetime2 = '2007-01-01 13:10:10.1111111';",null,null,null,null,null,"DECLARE @days INT = 365,"]
["SELECT 'year', DATEADD(year,1,@datetime2)",null,null,null,null,null,"@datetime DATETIME = '2000-01-01 01:01:01.111'; /* 2000 was a leap year */;"]
["UNION ALL",null,null,null,null,null,"SELECT DATEADD(day, @days, @datetime);"]
["SELECT 'quarter', DATEADD(quarter,1,@datetime2)"]
["UNION ALL",null,null,null,null,null,"Columna1"]
["SELECT 'month', DATEADD(month,1,@datetime2)",null,null,null,null,null,"2000-12-31T01:01:01.110"]
["UNION ALL"]
["SELECT 'dayofyear', DATEADD(dayofyear,1,@datetime2)",null,null,null,null,null,"Specifying scalar system function as date"]
["UNION ALL"]
["SELECT 'day', DATEADD(day,1,@datetime2)",null,null,null,null,null,"MyDatabaseName"]
["UNION ALL",null,null,null,null,null,"SELECT DATEADD(month, 1, SYSDATETIME()); /* The exact value returned depends on the day and time of statement execution */;"]
["SELECT 'week', DATEADD(week,1,@datetime2)"]
["UNION ALL"]
["SELECT 'weekday', DATEADD(weekday,1,@datetime2)"]
[null,null,null,null,null,null,"Columna1"]
["Columna1","Columna2",null,null,null,null,"2021-11-30 15:20:43.3933168"]
["year","2008-01-01 13:10:10.1111111"]
["quarter","2007-04-01 13:10:10.1111111",null,null,null,null,"Specifying scalar subqueries and scalar functions as number and date"]
["month","2007-02-01 13:10:10.1111111"]
["dayofyear","2007-01-02 13:10:10.1111111",null,null,null,null,"SELECT DATEADD(month,(SELECT TOP 1 BusinessEntityID FROM Person.Person),"]
["day","2007-01-02 13:10:10.1111111",null,null,null,null,"(SELECT MAX(ModifiedDate) FROM Person.Person));"]
["week","2007-01-08 13:10:10.1111111"]
["weekday","2007-01-02 13:10:10.1111111"]
[]
["Specifying numeric expressions and scalar system functions as number and date"]
[]
["SELECT DATEADD(month,-(10/2), SYSDATETIME());"]
[]
["Specifying ranking functions as number"]
[]
["SELECT p.FirstName, p.LastName"]
[",DATEADD(day,ROW_NUMBER() OVER (ORDER BY"]
["a.PostalCode),SYSDATETIME()) AS 'Row Number'"]
["FROM Sales.SalesPerson AS s"]
["INNER JOIN Person.Person AS p"]
["ON s.BusinessEntityID = p.BusinessEntityID"]
["INNER JOIN Person.Address AS a"]
["ON a.AddressID = p.BusinessEntityID"]
["WHERE TerritoryID IS NOT NULL"]
["AND SalesYTD <> 0;"]
[]
["Specifying an aggregate window function as number"]
[]
["SELECT SalesOrderID, ProductID, OrderQty"]
[",DATEADD(day,SUM(OrderQty)"]
["OVER(PARTITION BY SalesOrderID),SYSDATETIME()) AS 'Total'"]
["FROM Sales.SalesOrderDetail"]
["WHERE SalesOrderID IN(43659,43664);"]
["GO"]
[]
[]
["DATEDIFF (Transact-SQL)",null,"pp.22115"]
[]
["Specifying constants for startdate and enddate",null,null,"Specifying numeric expressions and scalar system functions for enddate"]
[]
["MyDatabaseName",null,null,"MyDatabaseName",null,null,null,null,"MyDatabaseName"]
["SELECT DATEDIFF(day,",null,null,"SELECT DATEDIFF(day, '2021-01-01 09:53:01.0376635', GETDATE() + 1);",null,null,null,null,"SELECT DATEDIFF(day, DATEADD(day, 1, SYSDATETIME()), GETDATE() + 3);"]
["'2007-05-07 09:53:01.0376635',"]
["'2007-05-08 09:53:01.0376635');"]
[]
["Columna1",null,null,"Columna1",null,null,null,null,"Columna1"]
[1,null,null,304,null,null,null,null,2]
[]
["DATEFROMPARTS (Transact-SQL)",null,null,"pp.22126"]
[]
["MyDatabaseName",null,"--REQUIRE VERSION SUPERIOR A 2008",null,null,null,"MyDatabaseName",null,"--OK 2008"]
["SELECT DATEFROMPARTS ( 2010, 12, 31 ) AS Result;",null,null,null,null,null,"SELECT convert(date, '2010-12-31') AS Result;"]
[]
[]
["Columna1",null,null,null,null,null,"Columna1"]
[null,null,null,null,null,null,"2010-12-31"]
[]
[null,null,"MyDatabaseName",null,"--OK 2008",null,"MyDatabaseName",null,"--OK 2008"]
[null,null,"SELECT convert(date, GETDATE()) AS Result;",null,null,null,"SELECT convert(date, '20101231') AS Result;"]
[]
[]
[null,null,"Columna1",null,null,null,"Columna1"]
[null,null,"2021-10-31",null,null,null,"2010-12-31"]
[]
[null,null,"MyDatabaseName",null,null,null,"MyDatabaseName",null,"--OK 2008"]
[null,null,"SELECT GETDATE() AS Result;",null,null,null,"SELECT convert(date, STR(2010, 4) + STR(12, 2) + STR(31, 2)) AS Result;"]
[]
[]
[null,null,"Columna1",null,null,null,"Columna1"]
[null,null,"2021-10-31T16:05:34.843",null,null,null,"2010-12-31"]
[]
[null,null,null,null,null,null,"MyDatabaseName"]
[null,null,null,null,null,null,"SELECT convert(date, STR(DATEPART(year, GETDATE()), 4) + STR(DATEPART(month, GETDATE()), 2) + STR(DATEPART(day, GETDATE()), 2)) AS Result;"]
["SMALLDATETIMEFROMPARTS (Transact-SQL)"]
[]
["MyDatabaseName",null,"--REQUIRE VERSION SUPERIOR A 2008",null,null,null,"Columna1"]
["SELECT SMALLDATETIMEFROMPARTS ( 2010, 12, 31, 23, 59 ) AS Result",null,null,null,null,null,"2021-10-31"]
[]
[null,null,null,null,null,null,"MyDatabaseName"]
["Columna1",null,null,null,null,null,"SELECT convert(date, STR(YEAR(GETDATE()), 4) + STR(MONTH(GETDATE()), 2) + STR(DAY(GETDATE()), 2)) AS Result;"]
[]
[]
[null,null,null,null,null,null,"Columna1"]
[null,null,null,null,null,null,"2021-10-31"]

{"sheet":"config","index":6,"n_rows":5,"n_cols":1,"rows_kept":5,"cut":false,"hidden":false,"merged":[]}
[]
["Bases de Datos"]
["MyDatabaseName"]
["MyDatabaseName2"]
["MyDatabaseName3"]