sql-server

Ad-hoc retreival of data from SQL Server varbinary column

I would like to retreive some binary data from a varbinary(max) column in a SQL Server database for debugging purposes. What is the easiest way to get this data into a local binary file, preferably without having to write a throw-away console application? I have tried using SQL Server Management Studio (with the "results to file" optio...

Please tell me difference between running query directly and executing it using exec

Please tell me what is difference ==> if i write query directly in storedprocedure ==> and write query in string variable and than run it in exec in stored procedure. i am using ms sql server 2005 ...

exit from a stored procedure

i hv some loop and a condition..if codition is match then i want to stop or exit from the stored procedure..how to do that? while @@fetch_status=0 begin if x=0 'exit stored procedure end ...

Store a byte[] stored in a SQL XML parameter to a varbinary(MAX) field in SQL Server 2005. Can it be done ?

Store a byte[] stored in a SQL XML parameter to a varbinary(MAX) field in SQL Server 2005. Can it be done ? Here's my stored procedure: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[AddPerson] @Data AS XML AS INSERT INTO Persons (name,image_binary) SELECT rowWals.value('./@Name', 'varchar(64)') AS [Nam...

How can I exit an inner loop and continue an outer loop?

This is a follow-up to my previous question (Thanks for the answer, BTW!) If I have two loops: while @@fetch_status=0 begin set y=y+1 set x=0 while @@fetch_status=0 begin x=y+1 if y = 5 'exit the second do while and back to the first do while --> y=y+1 end end ...how can I exit from the...

SQL Server SPID and transaction scope

We are running several calls against a SQL Server database within a transaction scope using entity framework. Are we right is assuming that the SPID will be held for the duration of the transaction and that all calls will be made on the same SPID? ...

SQL Server Clustered Index: (Physical) Data Page Order

I am struggling understanding what a clustered index in SQL Server 2005 is. I read the MSDN article Clustered Index Structures (among other things) but I am still unsure if I understand it correctly. The (main) question is: what happens if I insert a row (with a "low" key) into a table with a clustered index? The above mentioned MSDN a...

How to find column names for all tables in all databases in SQL Server

I want to find all column names in all tables in all databases. Is there a query that can do that for me? The database is Microsoft SQL Server 2000. ...

Prevent SQL Server Table operations (INSERT and DELETE) on some tables

While working with some random sql queries on our databases, we may not want to insert or delete items to some of the database tables by just typing their names by mistake. So how to make them locked to the "editing", to be able to work safe. Thanks. ...

Accessing Active Directory Role Membership through LDAP using SQL Server 2005

I would like to get a list of Active Directory users along with the security groups they are members of using SQL Server 2005 linked servers. I have the query working to retrieve records but I'm not sure how to access the memberOf attribute (it is a multi-value LDAP attribute). I have this temporary to store the information: DROP TABLE...

Select return dynamic columns

I have two tables: Standards and Service Offerings. A Standard can have multiple Service Offerings. Each Standard can have a different number of Service Offerings associated to it. What I need to be able to do is write a view that will return some common data and then list the service offerings on one line. For example: Standard Id | D...

Import Excel 2007 into SQL 2000 using Classic ASP and ADO

I have the following code from a legacy app which currently reads from an excel 2003 spreadsheet on a server, but I need this to run from my machine which uses excel 2007. When I debug on my machine ADO does not seem to be reading the spreadsheet. I have checked all file paths etc. and location of spreadsheet that is all fine. I've he...

SQL Server instead of insert triggers - is there an easy way to modify a single column?

Given that SQL Server does not allow modification of the logical INSERTED and DELETED tables in a trigger, is there an easy way to change the value of a single column and not have to re-write the entire insert statement? For example, the table to which I am applying the trigger has 20 columns. I want to modify the value from the INSERT...

How do I add a record only if it doesn't already exist in SQL Server?

Hi, I have a project in C# with a Sql-server Database. In that database I have a table named 'Process' and columns named 'process_name', 'Full_Name' and 'Version' (all of the type:nvarchar(50)). I want to write a query wich will add the new process, only if it doesn't exist in the table yet. How can I do that? Many thanks, ...

Approach for altering Primary Key from GUID to BigInt in SQL Server related tables

I have two tables with 10-20 million rows that have GUID primary keys and at leat 12 tables related via foreign key. The base tables have 10-20 indexes each. We are moving from GUID to BigInt primary keys. I'm wondering if anyone has any suggestions on an approach. Right now this is the approach I'm pondering: Drop all indexes and ...

Customizing Mail Message in SSIS Event Handler

I want to add an email notification to an SSIS 2005 package event handler. I've added a Send Mail task to the event handler. I'd like to customize the email body to include things like the error description. I've tried including @[System::ErrorDescription] in the MessageSource field, but the mail message doesn't include the value of E...

SQL Server BEGIN/END vs BEGIN TRANS/COMMIT/ROLLBACK

I have been trying to find info on the web about the differences between these statements, and it seems to me they are identical but I can't find confirmation of that or any kind of comparison between the two. What is the difference between doing this: BEGIN -- Some update, insert, set statements END and doing this BEGIN TRANS ...

SQL Server 2008 R2 RTM on MSDN?

SQL Server 2008 R2 has supposedly been Released to Manufacturing. Does anyone know when it's supposed to show up on MSDN? ...

"Executing SQL directly; no cursor" error when using SCOPE_IDENTITY/IDENT_CURRENT

There wasn't much on google about this error, so I'm asking here. I'm switching a PHP web application from using MySQL to SQL Server 2008 (using ODBC, not php_mssql). Running queries or anything else isn't a problem, but when I try to do scope_identity (or any similar functions), I get the error "Executing SQL directly; no cursor". I'm d...

Collation conflict SQL Server 2008

Hello, I've been going around this but I haven't found a solution for my problem. My sql query is: SELECT dbo.Country.CtyRecID, dbo.Country.CtyShort, dbo.Notification.NotRecID, dbo.Notification.NotName, dbo.TemporalSuspension.TCtsCode, dbo.TemporalSuspension.TCtsCodeRecID, dbo.TaxPhylum.PhyName AS Taxon, dbo.TemporalSusp...