sql-server

Cascading auto-increment keys and C# DataSets - MS SQL vs MySQL

Hi Does anybody know why the cascading foreign key relationships to auto-incrementing primary keys in a .net DataSet behaves differently with MySQL vs. MS SQL? I'll flesh it out a bit. I created a parent table with an AI PK, and a child table with an AI PK and a foreign key field to the parent PK. Then I created a cascading relationshi...

SQL Server create a full field select fast

When writing a statement select * from tableName you get all the fields, however I want to get all the fields in the statement for better code, is there a tool to do it faster in SQL Server, to get select f1,f2,f3 from tableName which are all the fields in tableName ...

Help with this query

Please can you take a look at this query and point out what I'm doing wrong: update @output set fromdate = o.fromdate, todate = o.todate from ( select fromdate, max(todate) from @output as o left join status as es on o.number = es.empid and o.ccode = es.compcode and @status = es.status ) I'm try...

Aliasing a linked server?

I have a server which I need to have as a linked server to another server, using sp_addLinkedServer. My server's name is in the format "DepartmentName.CompanyName.com", which I can usually change to [blah.blah.com], but which I can't use in the SQL Server Management Studio View creator, because it keeps deleting my square brackets... O...

SQL Server: Test if DB is Single User

Hello. How test if the DB is in single user mode in a sql script? Thanks. Eduardo ...

To create a trigger in sql for my requirement

The following is my tables table1 ========= id col1 col2 ===================================== 1 firstrow firstrow2 2 secrow secrow2 table2 =========== id orignalvalue updatedvalue =============================================== 2 secrow2 ...

Conversion of decimal and date/datetime types into custom varchar equivalents

I am generating a flat text file via an SSIS package. The package reads data from a table, creates a fixed length text file and ftp's the file to a partner. The data arrives into my table via a process that I have control over so I can make adjustments based on suggestions. My quandry is this. I have a two fields, lets call them: Dat...

Is there a way to detect open readers on a SqlConnection?

I am getting the error "New transaction is not allowed because there are other threads running" in an application I am working on. It has arisen during refactoring and specifically during creation of a test suite. I realise from looking around that it means that I probably have a data reader still open when I am creating the transaction...

SQL statement nested too deeply in Microsoft Sharepoint site?

I'm editing a page on a site built with Sharepoint. I'm only editing small bits of html code here and there, and not touching any SQL statements. However, recently when I've tried to save said page I've come across an error page which reads the code below. Any ideas on how to fix this, or what the issue is? Thanks. Much appreciated....

What is zombie transaction?

I accidentally found zombie transaction is mentioned in SqlTransaction code. So, what is zombie transaction? ...

generate scripts automatically

Hi Guys, I need to generate automatic sql script of SP, views, triggers etc. Is there any tool available that i can use where i just need to put in the name for example SP name and it generates a create script for that for me. sql server 2005 Thanks ...

Exception with MS-SQL Server,JDBC and XA Transactions

Hi, I'm getting the following exception in my log when I try to perform an XA transaction: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc_SQLServerException: failed to create the XA control connection. Error: "The EXECUTE permission was denied on the object 'xp_sqljdbc_xa_init_ex', database 'master' schema 'dbo' I f...

Array picture storing on MS SQL

I need to store pictures (.jpg) in my table on MS SQL. What type of column I need to choose? If I always store three pictures, is there any array type in MS SQL to store in one column all three pictures ( like array in Oracle) ? ...

How can I set ALLOW_SNAPSHOT_ISOLATION ON on SQL Server without restarting the DB server?

I'm trying to run the following statement on a SQL server database: ALTER DATABASE myDB SET READ_COMMITTED_SNAPSHOT ON Query Analyzer just keeps spinning and nothing returns. I've read about other people experiencing this problem and that it should normally return fairly quickly, and the only way they've found around it is to restart t...

How to Configure a Stored Procedure to Access a Table in Another Database

I have two databases on the same SQL Server: Database A table 1 table 2 sproc x Database B table 3 table 4 sproc y sproc z I want to give user1 access to the database, but only through the EXECUTE permission on the sprocs. sproc x does a join between table 1 & 2, and user1 can execute. sproc y does a join between tables 3 &...

Column is invalid error when using derived table

I'm using ROW_NUMBER() and a derived table to fetch data from the derived table result. However, I get the error message telling me I don't have the appropriate columns in the GROUP BY clause. Here's the error: Column 'tblCompetition.objID' is invalid in the select list because it is not contained in either an aggregate function or...

Content download from within a Windows client - Best Practices

Our application is a Windows client (C++/MFC migrating to C#) that uses SQL Server Express as its data store. We release regular updates to the data the application works with. (Our users use the content data we provide as a basis for their own projects built using the client; the database stores their projects as well, to enable collab...

I need to show the monthly inventory data

I have a table some thing like as follows for Inventory details. InventoryTable. InventoryTableID DateCreated quantity ItemName ------------------------------------------------- 1 2010-02-04 12 abc 2 2010-03-10 4 abc 3 2010-03-13 5 xyz 4 201...

Opposite Of An Inner Join Query

can someone help me write sql for a scernerio like this: Table 1 2 columns: ID, Name Table 2 2 columns: ID, Name I want a query to show names from Table 1 that are not in table 2. So filter out all the names in table 1 that are in table 2 is the result query. Use ID for the filtering not name. This will help me in what I am tryin...

calculating "Max Draw Down" in SQL

edit: it's worth reviewing the comments section of the first answer to get a clearer idea of the problem. edit: I'm using SQLServer 2005 something similar to this was posted before but I don't think enough information was given by the poster to truly explain what max draw down is. All my definitions of max draw down come from (the firs...