sql-server-2008-r2

IntelliSense is not working in SQL Server Management Studio

早过忘川 提交于 2019-12-09 08:21:48
问题 We use SQL Server Management Studio 2008 R2. IntelliSense works with SA account perfectly. But it is not working with Windows Authentication user. The user has access master db with db_owner role but it's not sysadmin. How do I fix this issue? 回答1: You can try solution from these questions1 or questions2 and questions3. Or please try these steps as below: Enable IntelliSense: For all query windows, please go to Tools >> Options >> Text Editor >> Transact-SQL >> IntelliSense, and select Enable

Create rule to restrict special characters in table in sql server

随声附和 提交于 2019-12-09 06:11:23
问题 I want to create a rule to restrict special characters to be entered into a column. I have tried the following. But it didnt work. CREATE RULE rule_spchar AS @make LIKE '%[^[^*|\":<>[]{}`\( );@&$]+$]%' I dont know what I am doing wrong here. Any help would be appreciated. 回答1: Your can create a Check Constraint on this column and only allow Numbers and Alphabets to be inserted in this column, see below: Check Constraint to only Allow Numbers & Alphabets ALTER TABLE Table_Name ADD CONSTRAINT

Find Column dependency

半腔热情 提交于 2019-12-09 05:08:13
问题 How to find objects which depend on particular column of table. Ex: Table: SomeTable Cols: col1 pk, col2, col3 I want to find all the objects which are dependent on col1 (Pk) 回答1: Try this query, it will get you some results that i think you are looking for. To filter, search for the value in the c1.name or c2.name column. To look for all the references to a certain column, use the c2.name for the column name and the OBJECT_NAME(k.referenced_object_id) as the table which holds the c2 column :

Procedure or function expects parameter ' which is not supplied

笑着哭i 提交于 2019-12-09 03:58:48
问题 hello friends i face one issue for load the data to grid view. the page load event call the one method like loaddata() inside i write the code this using (SqlConnection Sqlcon = new SqlConnection(strCon)) { using (SqlCommand cmd = new SqlCommand()) { Sqlcon.Open(); cmd.Connection = Sqlcon; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SP_Marketing"; //cmd.Parameters.Add(new SqlParameter("@Sno", (object) ?? null.Value)); cmd.Parameters.Add(new SqlParameter("@pvchAction",

How to handle users and logins in Visual Studio Database Project?

偶尔善良 提交于 2019-12-09 03:03:55
问题 I've built a database in SQL Server 2008 R2 and am using Visual Studio 2010 Ultimate to create a database project for it. I've created both a SQL Server project and Database project to represent my environment based on this MSDN walkthrough. The schema comparisons for both projects work as expected and I'm able to replicate all changes server to project. However, it seems to have imported some environment specific configuration, such as logins, user/login mapping, local service accounts (e.g.

Rollback transaction from trigger

╄→гoц情女王★ 提交于 2019-12-09 02:52:59
问题 In MS SQL Server 2008 R2, we want a pre-insert and pre-update trigger which checks something and allows or rollbacks (via raiserror ) the running insert/update. Question : In INSTEAD OF trigger. Does one really has to explicitly write the insert or update? Because we want the default insert or update to be done and only do the "precheck". 回答1: Yes. You do need to write the explicit INSERT or UPDATE . The trigger runs INSTEAD OF the DML operation. If you leave the trigger blank then no action

preventing a specific record from being deleted

久未见 提交于 2019-12-08 19:37:27
I want to prevent a specific record from being deleted. This trigger works fine for that specific record. However, other records still remain when they're being deleted. Why? ALTER TRIGGER [Globalization].[CountriesTracker] ON [Globalization].[Countries] INSTEAD OF DELETE AS BEGIN SET NOCOUNT ON; IF ((Select COUNT(*) from [Deleted] Where [Deleted].[CountryId] = '36bd1536-fb56-4ec4-957e-1b3afde16c56') = 1) BEGIN RAISERROR('You can not delete this specific record!', 0, 0) ROLLBACK TRANSACTION RETURN END END How can I ensure that rows not matching the above condition are being deleted as expected

How to SET IDENTITY_INSERT ON in SQL Server 2008 for multiple tables at once

北战南征 提交于 2019-12-08 19:21:39
问题 I have two tables tblData1 and tblData2 and now I want to migrate records from another table with identity insert and I am trying to run a command as shown below SET IDENTITY_INSERT LP1.dbo.tblData1 ON GO SET IDENTITY_INSERT LP1.dbo.tblData2 ON GO INSERT INTO LP1.DBO.tblData1 (ID,DATA) SELECT ID,DATA FROM LP.DBO.tblData1 GO INSERT INTO LP1.DBO.tblData2 (ID,DATA) SELECT ID,DATA FROM LP.DBO.tblData2 GO SET IDENTITY_INSERT LP1.dbo.tblData1 OFF GO SET IDENTITY_INSERT LP1.dbo.tblData2 OFF GO But

How to give a user access to sys.master_files in SQL Server?

落爺英雄遲暮 提交于 2019-12-08 17:34:10
问题 I need to give a database user read access to the sys.master_files table. How can I do that? Currently the user has this permissions: Calling SELECT on sys.master_files returns an empty result. I also tested the same query with the sa user which works as expected. 回答1: for you to run successfully select * from sys.master_files the minimal permissions that you need to grant is as follows: GRANT VIEW ANY DEFINITION TO [texas_user] GO I have tested and it works fine on sql 2008 r2 regards

Error 175: The specified store provider cannot be found in the configuration, or is not valid

二次信任 提交于 2019-12-08 17:12:09
问题 I just joined a project and installed Microsoft Visual Studio Professional 2012 Version 11.0.51106.01 and Microsoft SQL Server 2008 R2 on a 64-bit machine. Another team member is able to build the solution from his machine, but from my machine I get the following error: Error 175: The specified store provider cannot be found in the configuration, or is not valid In my .edmx file, all of the code between the <edmx:StorageModels></edmx:StorageModels> tags is marked for the error. The relevant