Using SQL Profiler can I pinpoint to one DB - sql-server

Can I pinpoint SQL Profiler just to one Database, my server has around 50 Database and I just want SQL Profiler to check one Database because the site that uses that Database has gone very slow.

Yes, you can.
When you set your trace up, go to the Events Selection tab and click the "Show all columns" checkbox. Then the Database column appears and you can put a filter on the database name in Column Filters.

Related

Right click to query temporal tables not working

I have SQL Server Management Studio 2016 loaded with Microsoft's test database (WideWorldImporters) but for some reason, any table that is a temporal table does not give me the option of right clicking and selecting the last 1000 rows as all other non-temporal tables allow.
Am I missing something which needs to be installed or is there an alternative way of querying the table for data?
Right Clicking does not work. But in the session that created the table you can do any kind of query that can be done against any other table.

sql server profiler: How to know which db is being hit using sql server profiler

I have 2 application, connected to 2 different databases on one instance.
I am trying to trace some functionality using SQL Server Profiler(Standard Template) but difficult to understand which database is being hit by one application just by looking into the trace.
Kindly suggest how to know the dbname being hit by one application.
One option is to filter by each database name.
Under Trace properties > Events Selection tab > select Show all columns.
You should see the database name under column filters.
Enter the database name for the Like section and you should see traces only for that database.
You can also read more about this here
Use standard template (Default)
And you should see it.

Adding new rows that contain identities, defaults via SQL Server Management Studio GUI

In Enterprise Manager (SQL Server 2000-), you can add new rows to an existing table by right-clicking the table and selecting "Open Table". You get an MS Access-like grid with a single blank row at the bottom for adding new rows.
In Management Studio (SQL Server 2008+), the same functionality is available by right-clicking and selecting "Edit Top 200 Rows".
In the old Enterprise Manager version, any untouched columns are set with either their default value or new identity (if applicable). This happens as soon as focus leaves the row.
In Management studio, any values not explicitly typed-in are set to NULL (even if NULL is not allowed for the column). After focus leaves the row, there is a little exclamation icon to the left of the row with this tooltip:
"This row was successfully committed to the database. However, a problem occurred when attempting to retrieve the data back after the commit. Because of this, the data in this row is read-only. To fix this problem, please re-run the query."
Is there a setting somewhere to enable the old behavior? Or, is there a keyboard shortcut (similar to CTRL+0 == NULL) to indicate you want to use the default?
I feel like I must be missing something obvious--otherwise this view is pretty useless for quickly adding new rows.
I've found that this behavior only happens when SQL Management Studio is connected to a SQL 2000 database. When editing rows on a SQL 2012 database the primary key immediately updates and there is no error icon. I think the best workaround is to just continue to use Enterprise Manager if you need to make quick edits on SQL 2000 databases.
To clear the "to fix this problem please rerun the query" just right click on the read only row with the error and select "! Execute SQL".
the issue is not management studio
this will take place even on a front end application
the issue is having identity column in a table
for some reason this behavior started when SQL 2012 came to life

How to audit SQL Server 2008 queries through WCF Services?

I want to save any kind of log/tables with every query executed by my application.
I know I could do this by coding it (before I make any query, I insert a new row in a log table with the query and the user who is executing it.
I have read it can be done automatically but I'm not sure how can it work with WCF Services. I mean every query is going to be executed by the same SQL user and this wouldn't be very useful for audit operations (I need to know WHO made every query, and users will be validated against my own users tables).
Have you ever had a similar scenario? Thanks in advance!
As a starting point it may be worth looking into doing this via SQL Server Profiler. You can normally find this in the Tools Menu in Management Studio.
You can set up a trace to capture all SQL run on a server. More importantly you have a myriad of filter options which can be applied so that you only capture the data you are interested in (e.g. DatabaseName, UserName).
This information can be stored directly in a SQL Table, which should give you the abillity to join onto. Of course running anything like this will result in some overhead on the SQL box.
You can try the SQL Server Audit feature. It audits singe or groups of events both on server and database level. However, be advised that the database level auditing is available in SQL Server Enterprise and Developer editions only

Visual Studio DataSet Designer Refresh Tables

In visual studio datasource designer is there any way to refresh a table and its relations/foreign key constraints while keeping the custom queries?
The way I am doing it at the moment is removing the table and adding it again. This adds all the relations and refreshes all fields.
Also if I change a fields data type, is there a way to automatically refresh all the fields in the datasource? Again without deleting the table and adding it again.
Reason for this is because some of my TableAdapters have quite a number of complex queries attached to them and when I remove the table the adapter gets removed as well including all its queries.
I am using Visual Studio 2008 and connecting to a MySQL database.
Any1 have an idea?
Each table has a default query (The one on top with the check on it). When you dragged your tables in to the dataset to create the query, it wrote a SQL statement which it uses to schema your table. Keep that query simple, you might not actually use it in code, and you can always edit that query to update the table schema.
Every time you open the default query it connects to your datasource and allows you to select new columns that weren't in there before. If you want to update your existing columns, delete all the columns out of the table before you attempt to open the query. When you save the query, your updated columns get added back.
Make sure your connection string has permissions to view column information.
I reported this to MSFT but no response. The designer hangs all the time on the simplest of SQL statements. What I found that works for me is.
Add a new table to the designer.
Save it.
Shut down visual studio 2010.
Start VS 2010.
Add one or two more SQL statements and follow steps 2-4 again.
This is a pain in the neck but the only thing that stops Visual Studio dataset designer from hanging. I experienced in this same issue in VS 2008. I am connecting to Oracle but still shutting down VS and starting it back up works, but really, this is nonsense.
You can add/change/remove fields and relation ships, but i would suggest looking into NHibernate.
You should be able to right-click the dataset in solution explorer and select "Run Custom Tool" to refresh the table and it's query/relationships.
If that command is not there, check that the dataset properties has "MSDataSetGenerator" in the Custom Tool field.
Right click on your DataSet name and select Dataset Properties
Below the Query box you will see a button for Refresh Fields.
Click on Query Designer and the new field should show in your table list.

Resources