How to put a description in an sql server database - sql-server

I use SQL Server Express 2012 and have multiple SQL Server databases and sometimes it gets difficult to find out which is which. So I want to put a description on each database. But I am not able to find any such option in the management studio. Has anybody faced this problem and knows the solution

Got the answer now. We can use Extended properties.
Right click DBName in object explorer - > Properties -> Extended properties
In that I added "Description" under name and details under value. We can add more properties also if we want. Same can be done for Tables too

if you are using mssm you can use "Registered Server", that way you can name and describe them , even sort them in groups

Related

Find a procedure or table by name in SQL Server

A month or so ago I somehow managed to get a tiny widget showing in SQL Server 2008 where I could type the name of the procedure/table (never searched for anything else) and it would bring a list of matching items. I could then right click on the one I wanted -> Click (I believe) "synchronize" and it would bring the said item in the Object explorer, from where I could do whatever.
The widget I'm looking for was part of SQL Server and i was able to pin it bellow the Object Explorer.
I've no idea how I found it and where it is, but it's extremely useful for fast searching of objects.
It was NOT a Select or an SQL statement of any kind.
The SSMSBoost add-in also provides such functionality.
Maybe some screenhots are helping to remember...
As already mentioned by Creep, it could also be RedGate SQL Search:
Use the 'Object Explorer Details' window (F7).
SSMS -> View - > Object Explorer Details
I think it could be one of those (free) products : redgate sql search or dbforge sql search

DataGrip / DBeaver cannot resolve table / column names

I'm connected to my universities' SQL server (Microsoft driver). I've tried using both DataGrip from Jetbrains and DBeaver to connect. Everything seems to be fine when I execute a query, however neither DataGrip nor DBeaver is giving me help with table or column names. In fact, DataGrip keeps telling me "Unable to resolve..." even if I type in the whole name (as I said the query executes just fine). Example screen shot:
I'll be really grateful for any suggestions.
This issue is related to DataGrip's intellisense, a similar issue was posted to IntelliJ's community forms here.
This answer relates to DataGrip 2017.1.5 (is likely applicable to other versions as well):
After creating the initial connection to your server, open the Database tool window using:
(ALT + F1) or
(View -> Tool Windows -> Database).
Listed beneath your server connection you will see a "Schemas..." item, double click it. This will expand into a list of all DB schemas you have access to on that server.
Select the schemas you are interested in, and additionally expand each DB schema to select all child schemas for that DB.
Click the refresh button in the schema selection window to synchronize your settings (two arrows pointing at each other in a circle).
Image of Database Toolbar with DB/Schema selection
If they are DBO owned tables, qualify then as dbo.MyTable. Datagrip seems to want a schema (DBO) for objects in order to use intellisense.

Missing Schemas in Crystal Reports

A little bit of an odd issue here.
I have a database, hosted on SQL Server 2008 R2 (SP2), that has 10 different schemas that could be used for reporting purposes:
Please note, for company compliance reasons, I did redact this image to the bare essentials.
Now, when I go to create a report, and connect to the database in question, the only schemas that are presented to me are those starting with lm_:
Again, redacted...
Now, for the purpose of the report I need to build, I need to be able to select against tables that are in one of the ls_ schemas.
My question is, in Crystal Reports 2013, how do I make all available schemas visible for use in a report?
Other important things to note:
I am able to log into SSMS as the same account I am using to connect to the database in Crystal Reports, and am able to successfully run queries against the schemas in question.
The account I am connecting to the database as, in both SSMS and CR, has full administrative access/capabilities against all schemas in the database in question
Points 1 and 2 would suggest that this is not a security related issue
I am connecting to the database in CR through an ODBC connection created on my system through ODBC Data Source Administration (32-bit) - as a System DSN
The ODBC Data Source uses the same administrative account being used directly in CR and SSMS
Thank you in advance for your help. Please let me know if there is any additional information that I can provide to help solve this issue.
I faced similar issue few years back, and as per my experience it has nothing to do with database and it is within the crystal reports where a registry value is set to minimum value which will restrict the display of schemas or tables
Check below link which will show you the path to change registry.
forumtopics.com/busobj/viewtopic.php?p=1004707
I would suggest you to first take back up of the original data and then change the value
Maybe this:
On the menu bar, select File –> Options.
Click the “Database” tab.
Uncheck the “Stored Procedures” option.
Someone on another forum said that worked but he did not know why.
There is a setting in Crystal under File-->Options-->Database where one can set owner like %. Perhaps your Crystal install has an old setting limiting your visible schemas?
For any one in 2022 who is facing this problem. Check the following:
Open odbc, 32 bits odbc.
Select your datasource and click configure
Click details
Select Metadata tab
Uncheck Disable Schema support and click Ok.
Solved, this is tested and working

SQL Server Management - Index propertiers keyboard shortcut?

While doing development in SQL Server Management Studio (SSMS), I frequently want to check the properties of a number of index on a specific table from within the Object Explorer:
Pulling up the index properties to see the columns included in the index, one can double-click the index name in Object Explorer, or alternatively use the Menu Key and then using Up to select Properties, and then hitting Enter.
I checked the SQL Server Management Studio Keyboard Shortcuts list, but did not manage to find the answer to my question.
Is there a one-key shortcut that could be used to pull up the index properties instead?
I have just tried to find any context menus registered in SSMS concerning Index in Object explorer, but unfortunately it looks like that it is 100% built dynamically. So it is impossible to assign a shortcut. Generally, you can assign shortcut on any command, that is registered as menu command in SSMS. But no luck here.
No, I don't believe so. Usually if someone wants that level of speed in accessing information about indexes, they'll just issue an sp_helpindex command in T-SQL or query sys.indexes for the information they want.

Can't gain access to my database created though Visual Studio?

I have created a database emailDatabase, its stored in
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
In Visual Studio, I use the Server Explorer, click the add new connection button.
The add connection dialog box appears.
Under server name I use the dropdown box and select DEV-5\SQLEXPRESS. I use Windows authentication.
In the Connect to section at the bottom, the dropdown displays: Master, Model, msdb and tempdb and does not display my emailDatabase.
So I select Attach Database File and click browse and follow
local C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
and select my email database.
The following error occurs :
emailDatabase
You don not have permission to open this file.
Contact file owner or an administrator to obtain permission.
I think my problem is i saved my database wrong, I need to make a back up or something like that. if that's the case please tel me how to make a backup and so on. I really need to move forward from this problem.
When I created my database I right-clicked on databases in SQL Server Management Studio and said new database, then I added columns with a query. then file save all.
How can I get a copy of my database file with all the permissions I need to use it in visual Studio??
When you create a database on the server (using SQL Server Management Studio), you don't have to (and should not!) fiddle around with the database file(s) anymore - let the server handle that for you.
Instead: do a Add Connection in Visual Studio and then specify the server instance (DEV-5\SQLEXPRESS) and the database name (emailDatabase) in your connection dialog.
With this, you're connecting and using a SQL Server database the way it's intended to be used - on the SQL Server instance itself. This is much easier, and much less hassle, than having to struggle with "free-floating" .mdf files and attaching them to your solutions and stuff like that....
So here - fill in DEV-5\SQLEXPRESS into your "Server name" dropdown, and then use the "Select or enter database name" option and enter your database name (or pick it from the dropdown) - it should be there!
DO NOT use the "Attach a database file" option - this is the free-floating .mdf "feature" which is rather clumsy and hard to use and error-prone - again: I recommend not using that...
Had the same problem and I realised the problem was not in VS2010 but my SQLserver.My instance name is OMAFANO ,and that's what my MSSQL connected to under Server Name. Now here's the catch,click on that and connect to OMAFANO\SQLEXPRESS and create all your databases and tables there if you want them to show up in VS2010 the way u stated up there. So under server name in VS2010 also write INSTANCENAME\SQLEXPRESS if you want to see your newly created databases etc. Take a look at the picture:
I thought I had it figured out but problems continue to pop up. So ...
IGNORE EVERYTHING BELOW THIS LINE.
After hours of tinkering I finally figured out how to use SSMS to connect to a SQLServer 2008 database that was created in VS2010, and it is relatively simple. But from the number of unanswered questions all over the place not well documented. Here's how to do it:
In VS right click the project in SolutionExplorer and select Add new item then select Data then SQLServer database. It will prompt you to save it in the app_data folder and create the folder for you if it doesn't exist.
Find the Ssms.exe file (on my system it's in C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE
Right click Ssms.exe and select Run as administrator.
After SSMS opens you can attach the project MDF. It will now be on your list of databases. The database name is a GUID.
You can even run aspnet_regsql against the database to add the Membership tables and sprocs.
IMPORTANT! You can manage this database with EITHER SMSS OR VS but not both at the same time. If you mess with the database from within VS using ServerExplorer you will break the SSMS connection. To fix that you will need to detach and reattach the database.
Run Your Visual studio As Administrator
Go to Visual Studio instance i.e C#,C++ etc
Right click > Run as Administrator
Then now It may work
To connect to a ssms2014 database from visual studio 2013, in the new connection wizard I had to change 'data source' from 'ms sql server database file' to '.net framework data provider for sql server..'. Then I was able to enter [computer name][username] for windows authentication.
I had the same issue, you just type your local server name "sara-PC" instead of
"sara-PC\SQLEXPRESS"
Now you can access your database easily, you can see it in your dropdownlist.
And also please dont use file access method to attatch database, thats not good way.
Also you can put ~....\Data and ~...\log file wherever you want by setting default location using server->rightclick->properties->Database settings.
Definitely this solves your issue.

Resources