Tag: ssms

insert SET STATISTICS TIME into a table

Let’s say I have the following statement: SET STATISTICS TIME ON; Select * from myTable SET STATISTICS TIME OFF; Which produces the following results in the messages tab in ssms: SQL Server Execution Times: CPU time = 0 ms, elapsed time = 1 ms. How Can I read Elapsed time value into a table/temp table/ […]

SQL SERVER 2008 new query window insert float using comma (,)

For some things I use new query window in our MS SQL Management Studio (Version: 10.0.1600.22 (SQL_PreRelease).080709-1414). I try to insert some data, and I can not use comma (,) when I try to insert float value. If I use dot (.) then value is multiplied by 1000 – and I don’t want that. Any […]

sql server catalog view to help generate stored procedure?

We can use sql-server’s catalog views to generate/re-create table(s) easily. I can run queries like select * from INFORMATION_SCHEMA.TABLES — Get all the table names find there column like this.. select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = ‘Publishers’ — Get the cols for publisher table I can query like this in sys.objects and/or in sys.foreign_keys […]

SQL Server debugging stored procedure using old version of code

This question already has an answer here: Debugging does not show current stored procedure version 4 answers

TSQL Prevent “FAST N” output by default

When I execute a TSQL query or a stored procedure that returns large number of records (1M+) by default it begins to display result while query is still executing. Is there way to prevent this and postpone returning of the result until the query execution is complete?

In TSQL, how to calculate time duration across 2 tables (login & logout logs)?

I need to calculate time duration from 2 tables (1 login log & 1 logout log), each recording a datetime of the action and the accountID associated with it. The aim to see how long each account has been logged in between corresponding login & logout. The table schema is as below (since this is […]

What is Cause for This while updating through Sql Data EDITOR is it Necessary to have primary key for table?

What is cause for this while updating through editor in SQL Server Management Studio. Is it necessary to have primary key for table? simple table tab1 schema Accid(int, not null),Bench1 (varchar(50),null),Bench2(varchar(50),null) Accid Bench1 Bench2 ——————————- 1 null null 1 null null 2 null null 2 null null 3 null null 4 null null update tab1 […]

MS SQL chooses invalid index

I had a problem that usp is much slower than simple query. I found an answer here: it’s slower because SQL chooses invalid index. So i can manualy choose it, but i guess it’s not really very good because index should be chosen based on statistics, but not on the query which is faster at […]

MySQL to MSSQL Query Translation

I am a novice when it comes to MSSQL and have been trying to convert the following MySQL query without any joy. I am connecting to a MySQL Database within Microsoft SQL Server Management Studio via ODBC. This works great and very simple queries work just fine. However the following query is a bit more […]

How to take screenshot of very large Database Diagram in SSMS?

I have created a diagram in SSMS for my database. There are approximately 120 tables are used in this diagram. the problem is that when I copy that diagram from the Edit->Copy Diagram to Clipboard and paste it to MSPaint it gives me error. Error getting the Clipboard data!. I have also tried Fast Stone […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.