ssms

SQL Server 2008: how do I grant privileges to a username?

依然范特西╮ 提交于 2019-12-17 03:28:08
问题 I need to be able to establish an ODBC connection through SQL Server authentication. In SSMS how do I grant permission for a user to be able to have ALL RIGHTS on a specific database? is there a way to do this graphically with SSMS? 回答1: If you want to give your user all read permissions, you could use: EXEC sp_addrolemember N'db_datareader', N'your-user-name' That adds the default db_datareader role (read permission on all tables) to that user. There's also a db_datawriter role - which gives

How can I automate the “generate scripts” task in SQL Server Management Studio 2008?

痴心易碎 提交于 2019-12-17 03:23:39
问题 I'd like to automate the script generation in SQL Server Management Studio 2008. Right now what I do is : Right click on my database, Tasks, "Generate Scripts..." manually select all the export options I need, and hit select all on the "select object" tab Select the export folder Eventually hit the "Finish" button Is there a way to automate this task? Edit : I want to generate creation scripts, not change scripts. 回答1: What Brann is mentioning from the Visual Studio 2008 SP1 Team Suite is

How to see query history in SQL Server Management Studio

会有一股神秘感。 提交于 2019-12-17 00:29:35
问题 Is the query history stored in some log files? If yes, can you tell me how to find their location? If not, can you give me any advice on how to see it? 回答1: [Since this question will likely be closed as a duplicate.] If SQL Server hasn't been restarted (and the plan hasn't been evicted, etc.), you may be able to find the query in the plan cache. SELECT t.[text] FROM sys.dm_exec_cached_plans AS p CROSS APPLY sys.dm_exec_sql_text(p.plan_handle) AS t WHERE t.[text] LIKE N'%something unique about

Transposing groups of rows with the same ID into another table

≡放荡痞女 提交于 2019-12-16 18:04:34
问题 I have a table, Demo1, where I have multiple similar DIM_KEY's for several different ATTR_NAME's (attribute names). I want to display a table with columns for DIM_KEY, UPC, DAIRY_CLM, KOSHER_CLM, FAT, and CALORIES where the matching values are the rows. This is the original table Demo1: [1]: https://imgur.com/a/KqayM1C This is what I want it to look like (table: Demo2): [2]: https://imgur.com/a/nwpoHhv I've tried inserting the rows from Demo1 into an empty Demo2 table but that didn't work out

Displaying row count from SQL server to program

倾然丶 夕夏残阳落幕 提交于 2019-12-16 18:02:11
问题 I am working on a program on C# VS 2015. In my program, there is a big text display box that generates message when I click a certain button to indicate an action is being performed. Anyway, I have a SQL script where it has queries for COUNT for some tables. I can run that script through my program. However , since row count displays total number of rows for a table and can only be viewed inside SQL server. I was wondering is there a way to execute my script and also display the ROW COUNTS

SQL Server Management Studio connection defaults to 'master' when selecting a database-specific object

老子叫甜甜 提交于 2019-12-14 03:43:25
问题 In SQL Server 2008 R2 Management Studio, if I right-click on an object inside a specific database and choose "Select top 1000 rows ..", the database connection for the query window always opens on 'master' while the table name is fully qualified as [database].[dbo].[table]. This makes it impossible to jump in and tweak out this query and insert joins, etc., to the statement without also fully-qualifying everything I add, or add a USE statement, or select the database from the drop-down menu.

Compare 2 SQL tables, if data does not match, put an integer value in 3rd table

本小妞迷上赌 提交于 2019-12-14 03:34:24
问题 Is there a way to compare 3 sql tables (A, B, C)? Which A and B have columns labled Name, TimeStamp in A, and Name, ScheduledTime in B. I need to compare these 2 columns and if they do not match up, put a numeric value of 1 into column 2 next to the name in table C. I'm fairly new to SQL but wasn't sure if this was possible. (Using SSMS) Table A looks like this. Name | Time ----------------- John | 7:00AM Joe | 7:07AM Tim | 7:25AM Table B looks like this. Name | Schedule --------------------

EXISTS in filter returning too many values

最后都变了- 提交于 2019-12-14 03:27:43
问题 I need to write a query that uses EXISTS, rather than IN, so that it will run fast. The filter is being fed so many parameter values that EXISTS seems like the only option. The difference is between a 20+ minute query and a 5 second query. This is the query I have: SELECT DISTINCT d.GROUP_NAME FROM [EMPLOYEE] e JOIN [DATA_FACT] d ON (e.KEY = d.KEY) WHERE d.DATE BETWEEN @Start and @End AND EXISTS ( select '1234567' -- @ID ) AND e.Location IN (@Location) ORDER BY d.GROUP_NAME ASC The problem is

Connect EF to SQL Server Management studio

时间秒杀一切 提交于 2019-12-13 21:50:08
问题 I'm using EF code-first and I want it to create the new database in SQL Server Management Studio instance instead of using the integrated SQL Server in Visual Studio. I added this to my web.config : <connectionStrings> <add name="BillFo" connectionString="Data Source=SELANL293;Initial Catalog=Billfo;Integrated Security=True"/> </connectionStrings> But it doesn't help. No nothing happens, nothing in the integrated SQL Server and nothing in my SQL Server Management Studio. How do I make it

Weird behaviour of Management Studio

自作多情 提交于 2019-12-13 18:16:16
问题 My sql managment studio is behaving weird with thi sql script. Bug in the Sql File . SqlScript. Steps to reproduce: Here is the sql file. Open it in Sql Management studio 2008. Comment the line between the identity insert on and off. cut it and paste it in new query window. Try to do more than once... it shows some weird behaviours 回答1: As I posted in the comments to your closed question the problem is that the string in the SQL Script when looked at in a Hex Viewer is