Mssql: Difference between revisions

From Halfface
Jump to navigation Jump to search
Line 21: Line 21:
  master
  master
==which version of mssql==
==which version of mssql==
  1> select @@microsoftversion/0x01000000 as version
  select @@microsoftversion/0x01000000 as version
  2> go
  go
==show time==
SQL Server 2000/2005
SELECT
CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond,
CONVERT(VARCHAR(8),GETDATE(),101) AS DateOnly
GO
SQL Server 2008
SELECT
CONVERT(TIME,GETDATE()) AS HourMinuteSecond,
CONVERT(DATE,GETDATE(),101) AS DateOnly
GO

Revision as of 07:30, 18 September 2014

Connect to database.

# tsql -S 192.168.0.1 -U user -P password -p 1433
locale is "en_US.utf-8"
locale charset is "UTF-8"
using default charset "UTF-8"

Show tables.

1> SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
2> go
TABLE_CATALOG   TABLE_SCHEMA    TABLE_NAME      TABLE_TYPE
master  dbo     spt_fallback_db BASE TABLE
master  dbo     spt_fallback_dev        BASE TABLE
master  dbo     spt_fallback_usg        BASE TABLE
master  dbo     spt_monitor     BASE TABLE
master  dbo     spt_values      BASE TABLE
(5 rows affected)

show databases

1> SELECT name FROM master..sysdatabases
2> go
name
master

which version of mssql

select @@microsoftversion/0x01000000 as version
go

show time

SQL Server 2000/2005

SELECT
CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond,
CONVERT(VARCHAR(8),GETDATE(),101) AS DateOnly
GO

SQL Server 2008

SELECT
CONVERT(TIME,GETDATE()) AS HourMinuteSecond,
CONVERT(DATE,GETDATE(),101) AS DateOnly
GO