SQL Server display server name other than connected one - sql

I am using SQL Server 2008 R2 to do my project.
I noticed that the when I execute following code:
print ##SERVERNAME
I've got a output "Server-01". However, I am actually connecting to "Server-03", and the above code is executed in "Server-03" as well.
So, may I know what cause such strange output? What is the mechanism behind this?
Thanks.

You're getting the wrong name because someone renamed this server after SQL Server was installed (possibly, it's been imaged as a SQL Server installation) and they've not followed the correct advice to get SQL Server's internal information updated after they did the renaming.

Related

Cannot find sequences in Microsoft SQL Server Management Studio 19

I have tried creating a sequence for my table in Microsoft SQL Server Management Studio 18. I have a syntax error for some reason (although I have checked multiple times the syntax), but I cannot even find the sequences folder for my database. I have also tried not writing the schema name, but the same error appears. What might be the problem? Where do I go wrong?
Here is a screenshot of the problem
First note that SSMS (SQL Server Management Studio) is just a client application that talks to a connected SQL Server instance in the background. So SSMS only passes your SQL statements to the connected SQL Server and shows you the results that SQL Server returns. Nothing more.
What is the version of the SQL Server instance to which your SSMS is connected? (You can check it quickly by executing the SQL statement PRINT ##VERSION.)
You should be aware that the CREATE SEQUENCE statement is only supported by SQL Server 2012 and higher.

Cannot connect SQL Server with instance - SSMS

I have a very strange and very frustating problem:
I'm trying to connect to an remote SQL Server Database, and i gotta some errors, like:
I've tried to connect to an specific remote SQL that has only one instance (SQL Server 2008). When i use the correct connection string, with server address and instance name, o get the following error:
But when i remove the instance name, it works:
Calling with customer's service from this server, they said that this server has only one SQL, so it allows you to connect without instance.
But my real problem is that i'm trying to connect to another server that has more than only one instances of SQL, so i'm getting the same old error:
And if i remove the instance, i get login error, cos my user and passwd was not found at default sql server.
I have tried several changes:
I've changed my Management Studio from 2017 to 2014.
I've formatted my computer last night, trying to solve this problem,
but i still got the same errors
I've asked to some friends to connect to this same server, exacly
the same way that i'm trying, and they sucessfully connected.
I really dont know what I'm doing wrong. Somebody knows how to help?
Thank you.

SQL Server 2005 Management Studio Express

I am using xp. I want to learn SQL.
I have SQL Server Management Studio Express.
I dont know how it works but when I open it ,it says couldn't connect to server.
It asks for server name and instance name, I don't have any idea where to find server name and instance name.
Also looked for solutions related to server name and instance name but dont find SQL manager. Please tell me how to practice SQL?
I am Learning for the first time.Please help me.
Hope these videos will help you to make first steps in studiyng SQL Server.
If you want to study just SQL (not specially SQL Server), you may like lessons on w3schools

See queries that hit SQL

Is there a way using sql 2008 Management Studio to look at the queries that hit the server? I'm trying to debug a program and I get messages like "Incorrect syntax near the keyword 'AND'". Since the queries are being dynamically generated it's a hassle to figure out what is going to the server.
Any help is appreciated!
There is a tool called Profiler that will tell you all information that you'll need. MSDN: http://msdn.microsoft.com/en-us/library/ms187929.aspx
I'm not aware of any method to do this using SQL Server Management Studio, but if you installed SSMS then you probably also installed the SQL Profiler. If you fire that up and run the TSQL_SPs profiler template, you can see every statement that's hitting the database.
Since the queries are being dynamically generated it's a hassle to figure out what is going to the server.
Why not just put the query that's generated into a message box, or print it to the console, or webpage, etc. ??
Trying to catch it at the DB server seems to be the long-way-around to debugging some simple ad-hoc queries.
Go to Management...Activity Monitor in the object explorer.
It's not live though, you will have to refresh it manually.
start up profiler from SSMS (Tools-->SQL Server Profiler), run a trace and select the T-SQL events
One option is to use SQL Server Profiler to run a trace. However, in some shops SQL Server permissions are set so only DBAs can run traces.
If you don't have sufficient rights to run a trace, then another option is to view the network traffic between the application that generates the SQL and box SQL Server is running on. WireShark works great for that.

How to automate a Visual Studio/SQL Server report

I'm currently working on a reporting tool for a company that conducts the same survey at different clients. So the analysis and report would be the same, except for the conclusions. The ultimate goal of the project would be a tool that automatically extracts, analyses the data and creates the report. SQL Server and Visual Studio are mandatory programs.
I'm completely new to all of this except for the SQL-language. After reading up on this and asking around the usage of stored procedures seemed the best option. If I interpret correct these should be stored in SQL Server and could then be envoked in Visual Studio
However, my problem is, I can't figure out how to connect to the external ODBC-server that holds the data in SQL Server 2005. It seems to me there is no way to connect to a remote server in SQL Server 2005. On the other hand, in Visual Studio 2005 I did manage to connect and extract data from the server.
Is this the right way to achieve my goal (repeatable/automated report)? If so, what am I doing/thinking wrong? If not, please enlighten me.
Thx in advance
Another way to do this is to use bcp...you can check this article to see if there are any answers here for you. There would be no remote server connections if you are able to run the command and the local box that contains the sql server.
You might be able to set up a linked server in SQL Server 2005 to connect to your remote server/database.