Archivo de la categoría: SQL Server

Bitacora de SQL Server

SQL Query for Counting Records per Day

This SQL query will add up the record count per day based on a column called “Timestamp.” Transact SQL SELECT DATEPART(YEAR, Timestamp) AS ‘Year’, DATEPART(MONTH, Timestamp) AS ‘Month’, DATEPART(DAY, Timestamp) AS ‘Day’, COUNT(*) AS ‘Visits’FROM tblVisitsGROUP BY DATEPART(DAY, Timestamp), DATEPART(MONTH, Timestamp), DATEPART(YEAR, Timestamp)ORDER BY ‘Year’, ‘Month’, ‘Day’ Results The results of this query will appear… Leer más »

CREATE SYNONYM ( join multiple databases in tableau sql server)

CREATE SYNONYM [dbo].[tbl1] FOR [db1].[dbo].[tbl1] The above code, if run on db2, would create an object tbl1 which would behave as a table under the dbo schema in db2, but would actually reference [db1].[dbo].[tbl1]. If you are on 2000, then no, it’s fully qualified names or nothing, I’m afraid. Nota: –>Ubicarse en la base donde… Leer más »