Archive for the ‘SQL Server 2000’ Category
Posted by jpluimers on 2012/08/21
Few people know about the INFORMATION_SCHEMA views that have been there since SQL-92.
Two funny things about that standard:
A few reasons I can imagine not many people know about the INFORMATION_SCHEMA:
- Not all relational database servers implement them, and of the ones that do implement them, not all versions implement all views.
That’s what this article is about; currently it lists only SQL Server 2000 and 2008 R2 (tried both) and PostgreSQL (verified docs), but I will update it as soon as I have run the script on other versions of SQL server and database vendors.
- It is hard to find the official ISO standards in a public way, and ISO itself sometimes puts things online, and at other times wants money for it
I remember the Y2K preparation era where the ISO-8601 standard was freely available at http://www.iso.ch/markete/8601.pdf, soon after the Year 2000, the PDF got locked behind a payment engine.
ISO suffers from heavy link rot too, for instance the ISO 3166 country codes used to be at http://www.iso.org/iso/prods-services/iso3166ma, but are now at http://www.iso.org/iso/home/standards/country_codes.htm. What about HTTP 303 or 302 redirect here guys?
Since SQL-92, the INFORMATION_SCHEMA (and its twin DEFINITION_SCHEMA) have been extended. The last extension in 2008. Together they allow SQL databases to be self-describing (I think no vendor has attained that) and the structures queryable in a standard way
In fact that is the main purpose:Â these views in INFORMATION_SCHEMAÂ are a very convenient standard way to query – in a vendor agnostic way – about tables, views, columns, etc. Read the rest of this entry »
Posted in Database Development, Development, Firebird, InterBase, ISO 8601, MySQL, OracleDB, PostgreSQL, Power User, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7, Sybase | Leave a Comment »
Posted by jpluimers on 2012/08/15
A few weeks ago, Bill Karwin did a must watch webinar on the prevention SQL Injection titled  “SQL Injection Myths and Fallacies“.
Bill Karwin (twitter, new blog, old blog, Amazon) is famous for much work in the SQL database community, including InterBase/Firebird, mySQL, Oracle and many more.
He also:
Anyway, his webinar is awesome. Be sure to get the slides, watch the replay, and read the questions follow up.
Watching it you’ll get a better understanding of defending against SQL injection.
A few very valuable points he made: Read the rest of this entry »
Posted in .NET, .NET 3.5, .NET 4.5, .NET ORM, ASP.NET, Batch-Files, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C++, Cloud Development, COBOL, CommandLine, Database Development, Delphi, Delphi for PHP, Delphi x64, Delphi XE2, Development, EF Entity Framework, F#, Firebird, FireMonkey, History, InterBase, iSeries, Java, JavaScript/ECMAScript, Jet OLE DB, LINQ, LLBLGen, MEF, Microsoft Surface, Mobile Development, PHP, PowerShell, Prism, Scripting, SharePoint, SilverLight, Software Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7, VB.NET, VBS, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools, Web Development, Windows Azure, WinForms, WPF, XAML, xCode/Mac/iPad/iPhone/iOS/cocoa | 1 Comment »
Posted by jpluimers on 2012/06/12
With old installations like Reporting Services 2000, you will often see that a few the reports on the server don’t match the ones in your version control system.
That’s why you sometimes want to download the .RDL files.
User nsaini shows on the SQLTeam forum:
It is easy …..
- Go to Report on Report Manager,
- Click properties of report,
- under the report definition you will see Edit and Update link…
- if you click on Edit you can open or Save the RDL files.
Tara Kizer shows how you get into the report manager:Â through this URL http://yourserver/reports
Easy :)
There are similar steps for SQL Server 2005 and SQL Server 2008.
If you have to do many of them, you can use Reporting Services Scripter to do it.
Even easier :)
–jeroen
via:Â SQL Server Forums – Copy .rdl from ReportServer.
Posted in Database Development, Development, Reporting Services, SQL Server, SQL Server 2000 | Leave a Comment »
Posted by jpluimers on 2012/05/23
Yes. Dorothy. There are people using the ADO .NET Entity Framework with SQL Server 2000 in parallel of moving towards a more modern Microsoft SQL Server version.
Entity Framework is lovely for developing data-centric applications.
By default, Visual Studio 2010 will target SQL Server 2008 as a database. That is fine, but it is kind of invisible it does: there is no property or dialog where you can change this.
What you have to change in order to have the Entity Framework send SQL Server 2000 compatible queries is to:
- Right click your .edmx file
- Choose “Open with”
- Choose the “XML (text) editor”
- Find the ProviderManifestToken attribute
- Change the value (usually from “2008”) into “2000”
- Save the .edmx file
- Build and run your application
A few caveats:
Read the rest of this entry »
Posted in .NET, .NET ORM, C#, C# 2.0, C# 3.0, C# 4.0, Development, EF Entity Framework, Software Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »
Posted by jpluimers on 2012/05/15
When in a DTAP environment, you cannot always have complete clean boundaries. Issues in production don’t reproduce in acceptance, you cannot develop in production, etc.
So sometimes you have to simulate or connect to Test or Acceptance Database Servers from a Develop workstation.
There it can get hairy to keep track of which applications connect to which database server.
That’s where the below batch file comes in handy: it scans your systems on connections to common TCP ports used by SQL server, then for each connection give you some process details (or – if you add a commandline parameter – all details that TLINK can get).
The batch file uses the built in tools tasklist, netstat, find and sc (the latter to show information on the local running SQL Services).
It also uses TLIST, which can be a bit awkward to get.
Read the rest of this entry »
Posted in .NET, Batch-Files, CSV, Database Development, Development, Scripting, Software Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | Leave a Comment »
Posted by jpluimers on 2012/04/25
I’ve been really busy lately with a couple of migration projects, so I totally missed the various SQL Server 2012 is Generally Available! announcements.
Which is important because for one client, this opens the possibility of move from SQL Server 2000 right to SQL Server 2012 Â in stead of SQL Server 2008 R2 and make a more smooth path for Azure.
–jeroen
via:
Posted in Database Development, Development, SQL Server, SQL Server 2000, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »
Posted by jpluimers on 2012/04/24
While transitioning from SQL Server 2000 to 2008, I recently had the “A severe error occurred on the current command. The results, if any, should be discarded.” Â occurring on SQL Server 2000 in the form as shown at the bottom of this message.
Many of the search results point you into the area of atabase corruption, or in using NVARCAR parameters with SQL Server 2000Â or SQL Server 2005 (the app didn’t use NVARCAR, nor did it use large VARCHAR parameters).
The cool thing on the SQL Server Forums – System.Data.SqlClient.SqlException: A severe error occurred on the current command post was that it summed up causes, and asked for more:
Posted – 06/17/2004 : 15:05:20
Rashid writes “Hi: Gurus I am getting these errors when I try to execute my application. According to MS knowledge base (http://support.microsoft.com/default.aspx?scid=kb;en-us;827366) these errors happen due to following resons
- You use a SqlClient class in a Finalize method or in a C# destructor.
- You do not specify an explicit SQLDbType enumeration when you create a SqlParameter object. When you do not specify an explicit SQLDbType, the Microsoft .NET Framework Data Provider for SQL Server (SqlClient) tries to select the correct SQLDbType based on the data that is passed. SqlClient is not successful.
- The size of the parameter that you explicitly specify in the .NET Framework code is more than the maximum size that you can use for the data type in Microsoft SQL Server.
None of these are true in my case. Are there any other reasons that can cause these problems..
There is one more: sending huge SQL Statements to your SQL Server is always a bad idea and gives this error too. Read the rest of this entry »
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Database Development, Development, Encoding, Software Development, SQL Server, SQL Server 2000, SQL Server 2008 R2, Unicode | Leave a Comment »
Posted by jpluimers on 2012/04/17
If you followed my blog, you probably already guessed that I’m assisting a client to prepare for a big SQL Server 2000 to SQL Server 2008 R2 migration. When not, you know now :)
I’m a fan of commandline, tools, and preconfigured settings. Which means that I’m in the midst of reconfiguring all my shortcuts to SQL Server 2000 tools to SQL Server 2008 equivalents.
When inspecting and changing LNK shortcut files, two tools are important:
- dumplnk: dumps a shortcut lnk file from the commandline
- shurtcut: creates a shortcut lnk file from the commandline
One of tools I many shortcuts for is the ISQLW aka SQL Query Analyzer, which I use far more than the SQL Server Enterprise Manager (more on SSEM in a future post).
Depending on the mode of authentication you use to connect to your SQL Server, there basically are two forms of shortcuts:
- SQL Server Authentication (using SQL Server username and password):
"C:\Program Files\Microsoft SQL Server\80\Tools\Binn\isqlw.exe" /S"servername[\instancename]" /U"username" /P"password"
- Windows Authentication (using the credentials of the currently logged in windows user):
"C:\Program Files\Microsoft SQL Server\80\Tools\Binn\isqlw.exe" /S"servername[\instancename]" /E
The former is less secure (so better to only store those shortcuts in a place that no other users can access).
From the ISQLW.exe syntax documentation:
Syntax
isqlw
[-?] |
[
[-S server_name[\instance_name]]
[-d database]
[-E] [-U user] [-P password]
[{-i input_file} {-o output_file} [-F {U|A|O}]]
[-f file_list]
[-C configuration_file]
[-D scripts_directory]
[-T template_directory]
]
The parameters /S, /U, /P and /E are very similar to the -S, -U, -P and -E ones from SSMS.exe (SQL Server Management Studio) with one distinction: there MUST be a space between each parameter and the value:
- SQL Server Management Studio (using SQL Server username and password):
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" -S "servername[instancename]" -U "username" -P "password"
- SQL ServerManagement Studio (using credentials for the currently logged in windows user):
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" -S "servername[instancename]" -E
Read the rest of this entry »
Posted in Batch-Files, Database Development, Development, Power User, Scripting, Software Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | 5 Comments »
Posted by jpluimers on 2012/02/24
I’m in the midst of a big migration traject.
One class of systems involved in the migration is SQL Server 2000 databases (yes, I know that SQL Server 2000 has been in Extended Support mode since April 8, 2008, that’s one of the grounds for migration).
Sometimes, you need SQL Server Enterprise Manager (a plugin to the Microsoft Management Console) to work on those databases to see what needs to be migrated (yes, this should be in the documentation, of which the ultimate form is the system itself ;-).
SQL Server Enterprise Manager has a nice feature that you can group SQL Server registration into SQL Server Groups.
However, it also has a limitation: you cannot add the same SQL Server to multiple SQL Server Groups. That is: unless you create an alias on the SQL Server, as aliases are not counted in the “unique” criterion.
Below are the top 2 links I found using “multiple databases” “sql server”  “enterprise manager”. Since I’m not sure the content of those will last, below are the full quotes.
Besides adding a SQL Server Alias (which has other uses as well), the most important steps are “6” in the first quote, and “1.6” in the second quote: your alias needs to point to the same IP address (or hostname) as your regular server.
How do I register multiple databases with MS SQL Enterprise Manager?
MS Enterprise Manager does not allow you to register the same database server multiple times. It is sometimes useful to create multiple registrations, if you want to connect to different databases on the same server. To workaround this, follow the steps below.
- Go to Start – Programs – Microsoft SQL Server – Select “SQL Server Client Network Utility”
- Go to Alias Tab
- Click “Add”
- In the “Server alias:” text box, enter a name you want to use to distinguish this database server
- In the “Network libraries:” section, select “TCP/IP”
- In the “Connection parameters” section, change the “Server name:” to your database server, i.e.; mssql01.discountasp.net
- Click OK
Once the Alias is created, you can register it using the same method described in this Knowledge Base article.
How can I open multiple databases in SQL Server Enterprise Manager?
- Create SQL Server Alias
(Please repeat the following steps if you want to open mutiple databases)
- Open SQL Server Client Network Utility.
- When Client Network Utility opens, click on the Alias tab.
- Click on the Add button.
- In the Server Alias text box enter a name for your SQL connection.
- Select TCP/IP under Network libraries
- Enter the IP address of the Server your SQL database is located on, in the Server name text box.
- Click on the OK button.
- Your Server alias will now be configured, click on the Apply button.
- Click on the OK button.
- Create SQL Server Connection in Enterprise Manager
(Please repeat following  steps if you want to open mutiple databases)
- Open SQL Server Enterprise Manager.
- When Enterprise Manager opens, right click SQL Server Group and select New SQL Server Registration.
- The Register SQL Server wizard will now open.
- Click on the Next button.
- From the Available Servers drop down menu, select the server alias you created earlier.
- Click on the Add button.
- The server should now be listed under Added servers, click on the Next button.
- When the next dialog box appears select The SQL Server login information that was assigned to me by the system administrator see above.
- Click on the Next button.
- Enter your Login name and Password ? this will be used every time you connect to your SQL server.
- Click on the Next button.
- Ensure that Add the SQL Servers to an existing SQL Server group is selected and SQL Server Group is selected for Group name.
- Click on the Next button.
- When the next dialog box opens you can click on the Finish button.
- Your SQL Connection will now be created.
–jeroen
via:
Posted in Database Development, Development, SQL, SQL Server, SQL Server 2000 | 1 Comment »
Posted by jpluimers on 2012/01/12
When moving databases across servers, you face the same problem as when upgrading servers: users are server specific, but permissions are databases specific. They are not bound by UserName, but through a SID (security identifier).
When adding the same UserName entries to a new server that already has the databases restored, you get error messages like these:
Error 21002 [SQL-DMO] User ‘account’ already exists
When adding the same UserName  entries, then restoring the databases, it won’t work, because the matching SIDs don’t exist.
There are many sites explaining the “Error 21002” and pointing to sp_change_users_login.
But sp_change_users_login (and the ALTER USER UserName WITH LOGINI = UserName2 in SQL Server 2005 and higher) is not the actual fix to the problem: it will re-add the user with a new SID, then correct the SID in the database currently in use.
Actually you are after “Orphaned” users: users that are defined in the various databases, but not present in the user list on the SQL Server instance. Running sp_change_users_login with the “Report’ parameter on the “new” server will show a list of orphaned users.
An even better way to show Orphaned Users is by running the ShowOrphanUsers script (thanks Vyas, wish more people republish your stuff with attribution!). In my own version (sourcecode is below), I have added an extra UserSID column of type varbinary(85).
In order to transfer users to a new server, you need a sp_help_revlogin stored procedure. Depending on the version of your SQL Server (7/2000/2005/2008), you need a slightly different version of a script that creates sp_help_revlogin for you. All versions are available at NetNerds.net.
–jeroen
via:Â Migrate/Transfer SQL Server 2008/2005/2000/7 Logins to SQL Server 2008.
USE master;
GO
IF OBJECT_ID ('dbo.ShowOrphanUsers') IS NOT NULL
DROP PROCEDURE dbo.ShowOrphanUsers
GO
CREATE PROC dbo.ShowOrphanUsers
AS
BEGIN
CREATE TABLE #Results
(
[Database Name] sysname COLLATE Latin1_General_CI_AS,
[Orphaned User] sysname COLLATE Latin1_General_CI_AS,
[UserSID] varbinary(85)
)
SET NOCOUNT ON
DECLARE @DBName sysname, @Qry nvarchar(4000)
SET @Qry = ''
SET @DBName = ''
WHILE @DBName IS NOT NULL
BEGIN
SET @DBName =
(
SELECT MIN(name)
FROM master..sysdatabases
WHERE name NOT IN
(
'master', 'model', 'tempdb', 'msdb',
'distribution', 'pubs', 'northwind'
)
AND DATABASEPROPERTY(name, 'IsOffline') = 0
AND DATABASEPROPERTY(name, 'IsSuspect') = 0
AND name > @DBName
)
IF @DBName IS NULL BREAK
SET @Qry = ' SELECT ''' + @DBName + ''' AS [Database Name],
CAST(name AS sysname) COLLATE Latin1_General_CI_AS AS [Orphaned User],
SID AS [UserSID]
FROM ' + QUOTENAME(@DBName) + '..sysusers su
WHERE su.islogin = 1
AND su.name <> ''guest''
AND NOT EXISTS
(
SELECT 1
FROM master..sysxlogins sl
WHERE su.sid = sl.sid
)'
INSERT INTO #Results EXEC (@Qry)
END
SELECT *
FROM #Results
ORDER BY [Database Name], [Orphaned User]
END
GO
Posted in Database Development, Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | 1 Comment »