sql-server

Access to Result sets from within Stored procedures Transact-SQL SQL Server

I'm using SQL Server 2005, and I would like to know how to access different result sets from within transact-sql. The following stored procedure returns two result sets, how do I access them from, for example, another stored procedure? CREATE PROCEDURE getOrder (@orderId as numeric) AS BEGIN select order_address, order_number fro...

How to check which locale is a .NET application running under, without having access to its sourcecode?

Context: I'm in charge of running a service written in .NET. Proprietary application. It uses a SQL Server database. It ran as a user member of the Administrators group in the local machine. It worked alright before I added the machine to a domain. So, I added the machine to a domain (Win 2003) and changed the user to a member of the P...

How do I do a simple 'Find and Replace" in MsSQL?

Question is pretty self explanitory. I want to do a simple find and replace, like you would in a text editor on the data in a column of my database (which is MsSQL on MS Windows server 2003) ...

How do I disable validation in Web Data Administrator?

I'm trying to run some queries to get rid of XSS in our database using Web Data Administrator but I keep running into this Potentially Dangerous Request crap. How do I disable validation of the query in Web Data Administrator? ...

Reading recommendations for: Microsoft SQL Server

Post your favorite book about Microsoft SQL Server (single book per comment please) or vote it up if someone has already listed it. Edit: Please include a small review or overview of subject matter and the reason for its applicability. ...

When/Why to use Cascading in SQL Server?

When setting up foreign keys in SQL Server, under what circumstances should you have it cascade on delete or update, and what is the reasoning behind it? This probably applies to other databases as well. I'm looking most of all for concrete examples of each scenario, preferably from someone who has used them successfully. ...

Copying relational data from database to database

Edit: Let me completely rephrase this, because I'm not sure there's an XML way like I was originally describing. Yet another edit: This needs to be a repeatable process, and it has to be able to be set up in a way that it can be called in C# code. In database A, I have a set of tables, related by PKs and FKs. A parent table, with chi...

How do you check what version of SQL Server for a database using TSQL?

Is there a system stored procedure to get the version #? ...

Default Integer type in ASP.Net from a Stored Procedure

I have a web page that has I'm hooking up a stored procedure on. In this SQL Data Source, I have a parameter that I'm passing back to the SP of type int. ASP seems to want to default to int32 but the number won't get higher than 6. Is it ok to override the ASP default and put in 16 or will there be a conflict somewhere down the road...

Why would I ever pick CHAR over VARCHAR in SQL?

I realize that CHAR is recommended if all my values are fixed-width. But, so what? Why not just pick VARCHAR for all text fields just to be safe. ...

Best way to transfer an xml to SQL Server?

I have been hearing the podcast blog for a while, I hope I dont break this. The question is this: I have to insert an xml to a database. This will be for already defined tables and fields. So what is the best way to accomplish this? So far I am leaning toward programatic. I have been seeing varios options, one is Data Transfer Objects (...

MS Access ADP Autonumber

I am getting the following error in an MS Access ADP when trying to add a record on a form linked to a MS SQL Server 2000 table: Run-time error '31004': The value of an (AutoNumber) field cannot be retrived prior to being saved. Please save the record that contains the (AutoNumber) field prior to performing this act...

SQL Error OLE.INTEROP

I'm getting an error whenever I load Management Studio or open a folder in the server explorer, etc. Additionally, If I try to create a new database it constantly is updating and does not finish. I have attached a screenshot of the error. Please let me know what I can do to fix this because it's really aggravating. ...

Do I really need to use transactions in stored procedures? [MSSQL 2005]

I'm writing a pretty straightforward e-commerce app in asp.net, do i need to use transactions in my stored procedures? Read/Write ratio is about 9:1 ...

SQL Select Bottom Records

I have a query where I wish to retrieve the oldest X records. At present my query is something like the following: SELECT Id, Title, Comments, CreatedDate FROM MyTable WHERE CreatedDate > @OlderThanDate ORDER BY CreatedDate DESC I know that normally I would remove the 'DESC' keyword to switch the order of the records, however in this...

Priority of a query in MS SQL

Is there a way to tell MS SQL that a query is not too important and that it can (and should) take it's time? Likewise is there a way to tell MS SQL that it should give higher priority to a query? ...

What is the best implementation for DB Audit Trail?

A DB Audit Trail captures the User Last Modified, Modified Date, and Created Date. There are several possible implementations: SQL Server Triggers Add UserModified, ModifiedDate, CreatedDate columns to the database and include logic in Stored Procedures or Insert, Update statements accordingly. It would be nice if you include implem...

What steps should be necessary to optimize a poorly performing query?

I know this is a broad question, but I've inherited several poor performers and need to optimize them badly. I was wondering what are the most common steps involved to optimize. So, what steps do some of you guys take when faced with the same situation? Related Question: http://stackoverflow.com/questions/39331/what-generic-techniq...

The Best Way to shred XML data into SQL Server database columns

What is the best way to shred XML data into various database columns? So far I have mainly been using the nodes and value functions like so: INSERT INTO some_table (column1, column2, column3) SELECT Rows.n.value('(@column1)[1]', 'varchar(20)'), Rows.n.value('(@column2)[1]', 'nvarchar(100)'), Rows.n.value('(@column3)[1]', 'int'), FROM @x...

Use Float or Decimal for Accounting Application Dollar Amount?

We are rewriting our legacy Accounting System in VB.NET and SQL Server. We brought in a new team of .NET/ SQL Programmers to do the rewrite. Most of the system is already completed with the Dollar amounts using Floats. The legacy system language, I programmed in, did not have a Float so I probably would have used a Decimal. What is your...