Saturday, November 25, 2017

How to get Host name and SQL Instance Name in T-SQL

Run


SELECT SERVERPROPERTY('MachineName') AS [ServerName],
       SERVERPROPERTY('ServerName') AS [ServerInstanceName],
       SERVERPROPERTY('InstanceName') AS [Instance],
       SERVERPROPERTY('Edition') AS [Edition],
       SERVERPROPERTY('ProductVersion') AS [ProductVersion],
       Left(@@VERSION, Charindex('-', @@VERSION) - 2) AS VersionName
or

SELECT @@SERVERNAME





How do I identify the particular Linux flavor via command line?

Try the below command.... It worked for me...

cat /proc/version

Once you know that you are running Red Hat for example, you can get to the point with:

cat /etc/redhat-release

Or on Debian:

cat /etc/debian_version

or in general :

cat /etc/*-release

Also you could use the following command

cat /etc/issue

T-SQL Insert Into with CTE

CTE doesn't work with Insert into in nested queries.

With AS has be the first line of query.

and Insert Into can only work if the query finally ends with Insert into clause.

Work around is to split the query in 2 parts.

Where store one set of results in Global temp table.

like

select * into ##ramit from( select * from ----) as temp;