New answers tagged

0

I'm assuming that you have no foreign key constraints on the phone column and you have a Primary Key defined: DELETE FROM foo_schema.bar_table WHERE primary_key_column NOT IN (SELECT MAX(primary_key_column) FROM foo_schema.bar_table GROUP BY phone) This should group all ...


3

This is not possible: the display settings can not be specified per column. If you set the font to one which definitely supports relevant Unicode code points, you can use these characters instead of relying on a legacy symbols font, while still having normal characters available. For example "Arial Unicode MS" supports CHECK MARK (U+2713) and HEAVY BALLOT ...


0

I recommend saving your sqlcmd variables file in 'C:\Users\your_nt_login_name\AppData\Local\Temp' and referencing it from all my projects as $(TEMP)\sqlcmd_variables.sql.


1

SSMS has no equivalent shortcut to the CTRL+B shortcut from Query Analyzer. In my opinion, the best alternate feature is the ability to have query & results in separate tabs. In this way, I can flip between full-screen query & results easily, and maximize screen real estate for both. To enable this in SSMS: Go to Tools-->Options... In the left ...


1

I don't think so. These settings are stored along with a bunch of other UI configuration in a binary file in your user profile directory.


0

I'd been also curious about why sometimes some cost is displayed as 100%, 200%, 300%...and even more. After analyse xml file of query plan, i got it. The cost percentage = my EstimatedTotalSubtreeCost / parent node's EstimatedTotalSubtreeCost For example, your query plan shows Clustered Index Insert take cost 914%, to understand how it calculate this ...


6

I would say don't ever use the "Take Offline" thing in the GUI unless you know for a fact that the database is not in use. By anything. That's hard to know without doing some legwork, so why not save this script somewhere and always use this? USE [master]; GO ALTER DATABASE $dbname$ SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO ALTER DATABASE $dbname$ SET ...


0

If the stored procedure only returns one result set, and you know the column names in advance, then you can create a temp table and Insert #TableName Exec ProcedureName. You would then select the value you want into a variable from the temp table, and run the procedure again. If it only returns one result set but you don't know the column names in advance, ...


0

I found that the distribution and publication wasn't correctly disabled. When I tried to run the disable the publishing and Distribution (as seen in my image above) I was getting an error that the process couldn't complete because the distribution database was still in use. so I used SELECT spid FROM sys.sysprocesses WHERE dbid = db_id('distribution') to ...


2

You could try a "script the script" approach by using the SQLCMD :out command to redirect output, with :connect and optionally :r to read the output, something like this: SET NOCOUNT ON DECLARE @tbl TABLE (Id int IDENTITY (1, 1),ServerName sysname, DbName sysname, IsDone BIT DEFAULT(0)) INSERT INTO @tbl (ServerName,DbName) VALUES (N'CZASQL-001', ...



Top 50 recent answers are included