sql-server-2008-r2

How to determine the effective permissions for a user of a SQL Server database through C#?

流过昼夜 提交于 2019-12-04 05:50:05
When I say effective permissions, I'm referring to the permissions listed when you go into the properties of a database in SQL Server Management Studio, click "Permissions", and then click the "Effective" tab. So far, I have been able to determine the explicit permissions with the following code: using Microsoft.SqlServer.Management.Smo; ... DatabasePermissionInfo[] permissions = database.EnumDatabasePermissions("username"); However, I still need to obtain the effective permissions. In this scenario, I added a login for a user and gave it the role of db_datareader and db_datawriter for a

Odd characters showing small table after using tableDiff

十年热恋 提交于 2019-12-04 05:44:56
问题 SQLServer tabeDiff is being used to sync DB's. The  character has been found in the destination table. I can find nothing on this anywhere, has anyone experienced this? Here is my scenario. Its a .bat file which runs it. Here is an example of a source table.field value: SM-33® After tableDiff this appears in the source table.field: SM-33® How can this be happening? The source is SQLServer 2008R2, destination is SQLServer 2005. 回答1: Are the two databases using the same collation? I would

Best way to extract segments / values from VARCHAR field in SET based SQL

寵の児 提交于 2019-12-04 05:08:07
问题 Take the following example data: SELECT 'HelpDesk Call Reference F0012345, Call Update, 40111' AS [Subject] UNION ALL SELECT 'HelpDesk Call Reference F0012346, Call Resolved, 40112' AS [Subject] UNION ALL SELECT 'HelpDesk Call Reference F0012347, New call logged, 40113' AS [Subject] What i would like to do is extract this data as follows: As you can see, i need to extract the Ref, Type & OurRef as seperate columns to ensure efficient set based SQL when processing the resulting emails. Usually

OPENROWSET BULK Permissions to Shared Folder

余生颓废 提交于 2019-12-04 05:03:21
问题 OBJECTIVE Use the OPENROWSET feature to JOIN data in a query against a text file. ERROR Leveraging the answer from @gbn on this question I am trying to open a row set just like the OP; though the format of the file is a bit different. However, I'm getting the following error trying to access a shared folder: Msg 4861, Level 16, State 1, Line 1 Cannot bulk load because the file "\MACHINENAME\Share\EC04.txt" could not be opened. Operating system error code 5(Access is denied.). BACKGROUND

Why is my using statement not closing connection? [duplicate]

梦想与她 提交于 2019-12-04 05:01:17
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: Entity framework 4 not closing connection in sql server 2005 profiler Well, lots of developers on stackoverflow are saying that I should not worry to close my connection: my using statement will close the connection for me, here and here and all over the site. Unfortunately, I do not see it happening. Here is my code: [Test, Explicit] public void ReconnectTest() { const string connString = "Initial Catalog

Pass A User-Defined Table to a Stored Procedure

断了今生、忘了曾经 提交于 2019-12-04 04:46:15
I have a User Defined Table that I am passing into a stored procedure from within a stored procedure. DECLARE @tmpInput MyTableType; --Table is populated from an INPUT XML exec ValidateInputXML SELECT * FROM @tmpInput TI WHERE TI.EntryType = 'Attribute'; Now this isn't giving me an error, but when I run a select from with the ValidateInputXML the table has no data. You can also use Table-Valued parameter for your stored procedure. E.g. /* Create a table type. */ CREATE TYPE MyTableType AS TABLE ( Column1 VARCHAR(50) , ........ ); GO /* Create a procedure to receive data for the table-valued

Ad hoc updates to system catalogs are not allowed

邮差的信 提交于 2019-12-04 04:42:14
问题 So I'm trying to manually update hash for one user. I tried updating view, as tables are not visible. I tried starting in single user mode, changing "sp_configure 'Allow updates',1", and so on, with no luck. Is there any way. I don't know passwords, just hashes, as updating from 2000 SP4 to 2008 R2 failed, and I need to have credentials on 2008 R2, just like on old 2000. 回答1: The sp_Configure 'Allow Updates' setting has had no effect since SQL Server 2005, it will still "work" but it won't do

Database “cannot be opened because it is version 661” when attaching .mdf file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 03:50:11
问题 I am trying to attach MvcMusicStore.mdf to my .\SQLEXPRESS instance (sql server version 10.0.2531) in sql server 2008 R2 management studio. I got the db from this project: http://mvcsitemap.codeplex.com/releases/view/67151 When i am trying to attach i am getting an error?: The database 'C:\PROJECTS\CODEPLEX\TFS10\MVCSITEMAP\BRANCHES\3.1.0\SRC\MVCSITEMAPPROVIDER\MVCMUSICSTORE\APP_DATA\MVCMUSICSTORE.MDF' cannot be opened because it is version 661. This server supports version 655 and earlier. A

append currency symbol to result of sql query

故事扮演 提交于 2019-12-04 03:50:08
问题 The result of a sql query select PayerDate,PaymentAmount from Payments PaymentAmount - decimal Date Amount 12/11/2012 34.31 12/11/2012 95.60 12/11/2012 34.31 is that possible to get the result of query as below: Date Amount 12/11/2012 $34.31 12/11/2012 $95.60 12/11/2012 $34.31 I have tried but couldn't find much info on this. 回答1: you can concatenate it on your projection statement, In MySQL, SELECT PayerDate, CONCAT('$', PaymentAmount) PaymentAmount FROM Payments In SQL Server, SELECT

USE DB that may not exist

余生颓废 提交于 2019-12-04 03:43:45
问题 I have a script that has a USE DATABASE statement. The script runs perfectly fine if the database exists. If it doesn't exist, it fails with the message "the database doesn't exist", which makes perfect sense. Now, I don't it to fail so I added a check to select if the DB exists on sys.databases (which I will represent here with a IF 1=2 check for the sake of simplicity), so, if the DB exists (1=1), then run the "use" statement. To my surprise, the script kept failing. So I tried to add a TRY