sql-server-2005

Do statistics referencing a column prevent that column from being dropped?

笑着哭i 提交于 2019-12-12 08:22:22
问题 I'm trying a very simple drop column statement: alter table MyTable drop column MyColumn and receiving several errors along the lines of Msg 5074, Level 16, State 1, Line 1 The statistics '_dta_stat_1268251623_3_2' is dependent on column 'MyColumn'. followed ultimately by Msg 4922, Level 16, State 9, Line 1 ALTER TABLE DROP COLUMN MyColumn failed because one or more objects access this column. I didn't think statistics prevent a column from being dropped. Do they? If so, since these are

LINQ to SQL : Too much CPU Usage: What happens when there are multiple users

你离开我真会死。 提交于 2019-12-12 08:18:34
问题 I am using LINQ to SQL and seeing my CPU Usage sky rocketting. See below screenshot. I have three questions What can I do to reduce this CPU Usage. I have done profiling and basically removed everything. Will making every LINQ to SQL statement into a compiled query help? I also find that even with compiled queries simple statements like ByID() can take 3 milliseconds on a server with 3.25GB RAM 3.17GHz - this will just become slower on a less powerful computer. Or will the compiled query get

Setting Identity to on or off in SQL server

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 07:46:31
问题 I want to set Is Identity property of a column to off and after inserting an explicit value setting it to on again.I've written this query : SET IDENTITY_INSERT Tbl_Cartoons OFF Although it executes successfully ,nothing changes in the table design. Please suggest a solution ,It's really crucial. 回答1: All the line you've given does is to disable the identity so that you can insert specific values into your identity column - usually this is needed for one-offs such as moving data around. The

SQL Server - How to Grant Read Access to ALL databases to a Login?

一个人想着一个人 提交于 2019-12-12 07:39:57
问题 I need to give a new login read access to all 300 databases on a server. How can I accomplish this without checking 300 checkboxes in the user mapping area? 回答1: One way would be to Set "Results to Text" on the query menu in SSMS then execute the below. It doesn't actually make the change but generates a script for you to review and execute. SET NOCOUNT ON; DECLARE @user_name SYSNAME , @login_name SYSNAME; SELECT @user_name = 'user_name', @login_name = 'login_name' SELECT ' USE ' + QUOTENAME

How do I use full text search across multiple tables, SQL Server 2005

安稳与你 提交于 2019-12-12 07:36:33
问题 I have a full text catalog with two tables in it. tableA has 4 columns (a1, a2, a3, a4) of wich 3 are indexed in the catalog, a2,a3,a4. a1 is the primary key. tableB has 3 columns (b1, b2, b3, b4), two of which are indexed in the catalog, b3 and b4. b1 is the PK of this table, b2 is the FK to tableA. I want to do something like SELECT *, (ftTableA.[RANK] + ftTableB.[RANK]) AS total_rank FROM tableA INNER JOIN tableB ON tableA.a1=tableB.b2 INNER JOIN FREETEXTTABLE(tableA, (a2,a3,a4), 'search

Create a table without columns

随声附和 提交于 2019-12-12 07:24:44
问题 Can I create a table without any columns in SQL Server by t-sql? 回答1: A table is a collection of columns and rows. You need at least one column. 回答2: No. What would you use it for? 来源: https://stackoverflow.com/questions/2438321/create-a-table-without-columns

Sql query with special characters - how to handle?

痴心易碎 提交于 2019-12-12 07:23:18
问题 I've few emp names like john,1 devil's corn something like this Now when i'm searching for these names I'm using select * from emp where empname like ('john,1,devil's,corn') But I'm not getting expected values also I'm getting error because emp name contains special charecters like , and '. Can someone help me out how to solve this? 回答1: This assumes you have 3 discrete names in your example string Exact match. you need to double up quotes. select * from emp where empname IN ('john,1' ,

How to change the query to give last 15 weeks of data instead of last 15 days from the SQL Server

百般思念 提交于 2019-12-12 06:49:01
问题 The following query gives playing time of the users from the database on daily basis for the last 15 days. It adds 0 if no game is played. Now I want to get the data of playing time on weekly basis and 0 if no game is played in the whole week. So I want the query to give the last 15 weeks of data. Here is the daily query. CREATE PROCEDURE [dbo].[spGetPlayingTimeOfthepeoplesPerDay] @email NVARCHAR(50) AS BEGIN SET NOCOUNT ON; DECLARE @MinDate DATE ,@MaxDate DATE ,@LastXDays INT SELECT

Doubt in creating a Sierpinski carpet using TSQL (set based)

◇◆丶佛笑我妖孽 提交于 2019-12-12 06:04:42
问题 TSql Challenge 56 is over .... So I can safetly ask doubt on that I have tried to solve the problem as under WITH CTE AS ( SELECT id , level , 1 AS row , REPLICATE('X', POWER(3, level)) AS carpet FROM TC56 UNION ALL SELECT id , level , row + 1 , carpet FROM CTE WHERE Row < POWER(3, level) ) SELECT id ,row ,carpet FROM CTE ORDER BY id,row But the output is not at par with the one specified.. My output is as under id row carpet 1 1 X 2 1 XXX 2 2 XXX 2 3 XXX 3 1 XXXXXXXXX 3 2 XXXXXXXXX 3 3

Delete a record in DataGridView

穿精又带淫゛_ 提交于 2019-12-12 06:00:43
问题 I'm trying to delete a record in DataGridView but it is giving me this error: Must declare the scalar variable "@reg_id". My reg_id is the primary key column in the table. How can I resolve this? 回答1: You have to give default value to @reg_id in stored procedure where you declare this parameter. like @reg_id = NULL or @reg_id = ' ' 来源: https://stackoverflow.com/questions/5386842/delete-a-record-in-datagridview