How can I write a message to SQL profiler from Sql a query? - sql

I am troubleshooting for some SQL issue and I use SQL Profiler in order to diagnose some problem.
Is it possible to write some messages into SQL Profiler by adding some lines in a TSQL query?
thanks!

you can do by adding comment to your t-sql
like
-- My message
select * from table1
and send all to sql

The Application Name should also be different. For our installation, activity on the website gives an application name of ".Net SqlClient Data Provider", while queries from SQL Server Management Studio are designated as... well... "SQL Server Management Studio"

Related

Export from select Statement to JSON in SQL

I use Microsoft SQL Server Management Studio v17.2. I know that for exporting data to JSON must use method like this:
SELECT *
FROM table1
WHERE [conditions]
FOR JSON PATH, ROOT('root')
but when I use this code in SQL Server Management Studio, an error occurred:
Incorrect syntax near 'json'.
Please help me solve this error.
This doesn't have anything to do with Management Studio; the version of SSMS you're using is irrelevant. It has to do with the version of SQL Server you're running the code against, which is completely separate from the version of SSMS.
FOR JSON was introduced in SQL Server 2016. If you are not running 2016 or better (or Azure SQL Database), you'll need to upgrade, or use a different approach to get your data into JSON format.

Query Syntax for linked sql server

please help: I'm new to linked servers & in MS SQL I have successfully added one (from an MS Access file) as shown:
I'm having trouble querying this database here. What is the syntax? Thanks.
Okay, by simply using Management Studio in MS SQL I ran a SELECT query on the table through "Script Table as" (right-click) and with query results I was sure that this then is the format:
SELECT * FROM [RXPIPEDB]...[product]
Furthermore, I can run updates using this syntax:
UPDATE [RXPIPEDB]...[Product]
SET X = ..something..
Of-course for the UPDATE query, you must have set your LINKED SERVER properties > Server Options "RPC" & "RPC out" to TRUE.
Thank you all.
The query its OK. U have a problem in the configuration of linked server.
Check this: Run a Query from Linked Server (Oracle) in SQL Server2008 R2

can I use 'show SQL query' from crystal report and use in SQL server

I got some crystal reports, these are developed by someone but now I am migrating to SSRS. So when i go to 'show SQL query' from crystal reports it is showing some query but i can't understand properly where these columns coming from. Is there anyway to know exact SQL query so that i can use it in sql server to generate data sets for SSRS.
thanks
You can run Sql Profiler against your database server to see the exact Sql that Crystal Reports is running to generate the report.
Sql Profiler is a tool that comes with Sql Server (under Performance Tools in your Sql Server programs) that shows every Sql statement hitting the database. Run a trace on your Sql Server through Sql Profiler then run your report and Sql Profiler will show you the exact Sql statements that your Crystal report is running against the database.
One option would be split the query manully and see the select and where clause using or if you have access to database run the query over the database to check what all columns it is returning

How to check SQL Server 2008 script will work properly on SQL Server 2005

Is there a way (a tool) to check that a SQL Server 2008 script will run on SQL Server 2005?
Open up SQL Management studio, rt mouse click on the database name, select properties, select option, set compatability level. Test. A far as is known, when the compatabailty level is set to a (lower) level, functionality is disabled and errors raised entirely in line with the selected level. MS are a bit relctant to comit http://msdn.microsoft.com/en-gb/library/bb510680.aspx but in practice I've not found any issues. You can of course install an instance of the 2005 build and bulk insert for a really thorough check.
You can use SQL Fiddle for SQL Server 2008
At the left top you can select the RDMS

Unable to Import a database from Microsoft SQL Server Management Studio to phpmyadmin

Hey folks, the person I am buildling a website for decided to design their own database. They used Microsoft SQL Server Management Studio to build it and such. Now that they are done with the database they exported it to a text file (Tasks -> Generate Scripts). Now when I try to import the file into phpmyadmin I get the following error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[master] GO /****** Object: Database [Butterbakers] Script Date: 02/15/201' at line 1
The database code is here: http://zamn.pastebin.com/Y3u7MpZ9
phpmyadmin is for MySQL.
Microsoft SQL Server is a different DBMS.
Large parts of the SQL Syntax is DBMS/vendor specific.
The MySQL Workbench has a feature to "Create EER Model from existing Database".
This may be a try but you need a jdbc connection to the MS SQL Server and MySQL...
Converting DDL to a different DBMS is all but easy. And if you're done this doesn't guarantee that an probably already existing application is still working with the other DBMS.
Not switching DBMS and using the free MS SQL Express could be an option.
First decide for a DBMS and restart form zero is surely the cleanest and less painful solution.
With SQL Compare (http://www.red-gate.com/products/sql-development/sql-compare/) and SQL Data Compare (http://www.red-gate.com/products/sql-development/sql-data-compare/) , you can synchronize different DB.