We are currently using SQL Server 2000 but will soon be moving to 2008. I am looking for a way to group related stored procedures into folders. SQL Server 2000 does not seem to have this ability and from my searches it looks like 2008 does not either. This seems like a basic feature that most users would want. Wouldn't it make sense to put all generic stored procedures that are shared across multiple projects in one folder and project specific procs in another?
It seems the way most devs do this now is by using some from of ID_SPNAME syntax and sorting them.
Grouping procs and functions by type in the UI would be nice, but Management Studio can't do it. Using SQL Server 2000, I've done what you suggest (prefixing objects with a grouping code and sorting). In 2005 and 2008, consider creating schemas to serve the same purpose, and grouping your objects in those. Note that the object names are prefixed with the schema name in the UI.
CREATE SCHEMA ShoppingCart AUTHORIZATION Joe
CREATE PROCEDURE AddItem ...
... will display in the UI as ShoppingCart.AddItem.
Schemas in Sql Server 2008
The most common way to do this (in SQL 2005/2008) is by using schemas:
HR.spCalculateEmployeeCompensation
HR.spCalculateContractorBonus
Web.spAppendWebLog
Web.spUserEndSession
Reporting.spGetCurrentYearSummary
Reporting.spGetLastMonthDetail
Not only will these visually organize themselves in the SSMS list, but you can apply different permissions to each schema.
Related
I need to share a few stored procedures into a single logic subset. In Oracle, I can create a "package" or class.
Is there a way do something similar in SQL Server 2012?
I don't want stay this procedures in main storage, I already have some hundreds of it.
Consider using different database schema (create your own) to logically separate your database objects (stored procedures). Packages don't exist in MS SQL.
I’m trying to define new external content types, I’m able to connect to SQL Server and define external content types from tables, stored procedures and views that were already in the database.
The problem I’m having is that I created a new SQL View in SQL Server with the data I want, but when I try to define a new content type, SharePoint doesn’t show me the new SQL View in Data Source Explorer.
I thought it could possibly be the way the SQL view was created, so I created a new test Table, a new stored procedure but that didn’t work either.
I tried “Refresh All” and deleting and re-creating the connection in Data Source Explorer, but nothing seems to work.
It seems that any views, tables or stored procedures that I created after a certain point in time are not available in SharePoint
I’m using SharePoint 2010 and SQL Server Express Edition with Advanced Services (64bit)
Any help is greatly appreciated.
Thanks in advance,
Silvio
Are there any automation tools to ease creation of tables and adding standard insert/select/update stored procs, rather than doing hand creation for a large number of tables ?
If i have 100 tables to create (and later ALTER) and their associated stored procs in SQL Server 2008, what is the most convenient way to do it ?
ADDED:
Are there tools to auto-generate nice class skeletons (with data fields) tied-up with corresponding tables ?
I am using C# .NET 4.0 in Visual studio 2010 and Microsoft SQL Server 2008.
We are starting off a new project from scratch, so it would be helpful to get tools for quick bootstrap from Design on paper to initial code.
Any other related suggestions are appreciated!
Use SSMS Database Diagrams to design you 100 tables because one only has to type the column name and can point and click for data type, primary key, nullability, foreign key, etc. Create a diagram for each functional grouping. When the design is done you can write a script which will write the SQL for the stored proc to do the insert/update for the tables.
As you create the script to write the script you could post your work here.
SQL Server 2005. Is there a sql query that will return a text field containing the same type of schema info as you would find in doing a right click table -> Script Table As -> Create To (or Alter To) from SQL Server Management Studio ?
I'm looking for a single/flat format that describes the entire table, including constraints, indices, etc.
I am aware of:
sp_help table_name
but that doesn't provide the single flat format I'm looking for. Ideally it would be in a scriptable format, such as the AlterTo result that could be executed against the server.
This is for a scheduled process that documents table schemas on a nightly basis for checking in to version control (SVN).
Not really. A table def is a collection of columns, constraints etc.
There is an SVN plugin that may help called ScriptDB4SVN. I've not used it personally, I'm going on hearsay.
Was searching the 'net again for an answer to this, and came across this SO question. It doesn't accurately capture all the same data as SQL Management Studios Create-to, but enough for my purposes (scripting the database structure for version control purposes).
There is no such command in SQL Server. This is primarily because the Scripting facilitiy is actually in SMO and not in SQL Server itself. There are a number of free console command-line tools that can do it that you could call via xp_CmdShell.
However, if you really want to do this from T-SQL, then you will need a script or stored procedure that enumerates all of the tables attributes, columns, column datatypes, defaults, nullabilty, etc. etc. and then reassembles it into a CREATE TABLE script. This is a Huge task. That's the bad news. The good news is that someone (Lowell Izaguirre) has already done this and posted it in this article (http://www.sqlservercentral.com/scripts/Miscellaneous/30730/) at SQLServerCentral.Com.
Enjoy.
Not really - you can either use C# (or VB.NET) and SMO (SQL Management Objects) to script out your database objects (tables and all), or you can use SQL to get the list of columns for a table:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Your Table Name here'
But I don't know of any easy way in SQL itself to create Create/Alter scripts for database objects, sorry.
Marc
I am trying come up with a way to pull the tables out of an Access database, automate the creation of those same tables in a SQL 2008 DB, and move the data to the new tables. This process will happen on a regular basis and there may be different tables each time.
I would like to do this totally in SSIS.
C# SQL CLR objects are an option.
The main issue I have been running into is how to get the Access table's schema and then convert that to a SQL script that I can run via SSIS.
Any ideas?
TIA
J
SSIS cannot adapt to new tables at runtime. (You can change connections, move a source to a table with a different name, but the same schema) So, it's not really easy to do what I think you are saying: Upsize an arbitrary set of tables in an Access DB to SQL (mirroring their structure and data, naming, etc), so that I can then write some straight SQL to transform the data into another SQL database or the same part of the database.
You can access the SSIS object model from C# and build a package (or modify a template package) programmatically and then execute it. This might offer the best bang for your buck, but the SSIS object model is kind of deep. The SSIS Team blog have finally started putting up examples (a year after I had to figure a lot of this out for myself)
There is always the upsizing wizard, and I'm sure there are some third party tools.