GO
IF EXISTS
(SELECT NAME FROM SYS.DATABASES WHERE NAME = N'EMPLOYEE TEST')
DROP DATABASE [EMPLOYEE TEST]
GO
CREATE DATABASE [EMPLOYEE TEST]
GO
USE [EMPLOYEE TEST]
GO
IF EXISTS
(SELECT * FROM SYS.OBJECTS
WHERE OBJECT_ID =
OBJECT_ID(N'[DBO].[EMPLOYEE]') AND TYPE IN (N'U'))
DROP TABLE [DBO].[EMPLOYEE]
GO
CREATE TABLE EMPLOYEE (EMPID INT, FNAME VARCHAR(50),
LNAME VARCHAR(50))
GO
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME)
VALUES (2021110, 'MICHAEL', 'POLAND')
GO
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME)
VALUES (2021110, 'MICHAEL', 'POLAND')
GO
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME)
VALUES (2021115, 'JIM', 'KENNEDY')
GO
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME)
VALUES (2121000, 'JAMES', 'SMITH')
GO
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME)
VALUES (2011111, 'ADAM', 'ACKERMAN')
GO
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME)
VALUES (3015670, 'MARTHA', 'LEDERER')
GO
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME)
VALUES (1021710, 'MARIAH', 'MANDEZ')
GO
SELECT * FROM SYS.OBJECTS where type='U' and oBJECT_ID = OBJECT_ID(N'[DBO].[EMPLOYEE]')
SELECT ROWID=IDENTITY(int,1,1) , EMPID, FNAME, LNAME
INTO EMPLOYEE2 FROM EMPLOYEE ORDER BY EMPID
SELECT name,compatibility_level,recovery_model_desc,state_desc FROM sys.databases
SELECT db_name()
SELECT db_name(database_id) as DatabaseName,name,type_desc,physical_name FROM sys.master_files
SELECT ROW_NUMBER() OVER (ORDER BY CustomerName ASC) AS ROWID, * FROM Customer
WITH [Customer ORDERED BY ROWID] AS
(SELECT ROW_NUMBER() OVER (ORDER BY CustomerName ASC) AS ROWID, * FROM Customer)
SELECT * FROM [Customer ORDERED BY ROWID] WHERE ROWID =2
with ven as
(
SELECT ROW_NUMBER() OVER (ORDER BY CustomerName ASC) AS ROWID, * FROM Customer
)SELEC * FROM ven WHERE ROWID =2
No comments :
Post a Comment