sql-server

How do I return a new IDENTITY column value from an SQLServer SELECT statement?

I'm inserting into an SQLServer table with an autoincrementing key field. (I believe this is called an IDENTITY column in SQLServer.) In Oracle, I can use the RETURNING keyword to give my INSERT statement a results set like a SELECT query that will return the generated value: INSERT INTO table (foreign_key1, value) VALUES (9, 'text') ...

Injecting a value into text

I have some contract text that may change. It is currently (non live system) stored in a database field (we determine which contract text to get by using other fields in table). I, however need to display a specific date (based on individual contract) within this text. IE (but Jan 12, changes depending on the individual contract): ...

Undocumented System Procedure 'sp_MSforeachtable' and the @whereand parameter

I'm attempting to use the undocumented system procedure sp_MSforeachtable. But I need to restrict the affected tables to those that start with "smp" and that are in the "dbo" schema. I was able to find how to find procedures that start with "smp". I simply do: sp_MSforeachtable @command1=' print ''?''', @whereand=' and name like ''smp%...

The permissions granted to user 'servername/iusr-username' are insufficient for performing this operation. (rsAccessDenied)

I have tried everything that most forums have said and still cannot get other people in the network to see this report. Here's the things I have tried: in servername/reports under properties tab i have added my user "domain/username" and given him all 5 roles (Browser, Content Manager, My Reports, Publisher, Report Builder) in the sit...

SQl Server tables: to heap or not to heap?

I have recently noticed that we have a number of tables stored in heaps (no clustered index). Would you create clustered indexes on them selectively, across the board, or not at all? Any other wisdom or advice? There are some "codes" tables with 25 or so rows. However, there are several with well over a million rows. EDIT of the "bi...

What does error 0xC02020C4 mean in SSIS?

I get this error with this description. Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "OLE DB Source" (1) returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error i...

mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource

I am getting the above error using PHP trying to update an MS SQL server. Any idea what may be happening here? I am using a stored procedure as the basis of the update. I can successfully execute the sproc against the SQL server away from the PHP application. Any advice/help would be appreciated. ...

SQL Query to get a row, and the count of associated rows

I have two tables, like this: #Articles: ID | Title 1 "Article title" 2 "2nd article title" #Comments: ID | ParentID | Comment 1 1 "This is my comment" 2 1 "This is my other comment" I've always wanted to know, what is the most elegant way to get the following result: ID | Title | NumComments 1...

How to install a custom desktop application database to SQL Express?

Hi, I have a WPF desktop application that uses a custom database for storage. I need to prepare a setup project (from Visual studio 2008) (full setup, not ClickOnce). I can add the to the list of prerequisites to the application and it does install during the setup of the application. My question is: How can I run a script during th...

Handling multiple calls to BeginExecuteNonQuery in SQL Server 2008

Hi all, I have an application that is receiving a high volume of data that I want to store in a database. My current strategy is to fire off an asynchronous call (BeginExecuteNonQuery) with each record when it's ready. I'm using the asynchronous call to ensure that the rest of the application runs smoothly. The problem I have is that...

Need advice to query data from sql server on every 5 seconds and send it to other app.(.NET C#)

Hi All, I have a require ment to read data from a table(SQL 2005) and send that data to other application for every 5 seconds. I am looking for the best approach to do the same. Right now I am planning to write a console application(.NET and C#) which will read the data from sql server 2005(QUEUE table which will be filled through diff...

Generating a form from SQL Server database

Hi, Just wondering if anyone knows of a product (free or licensable) that allows you to generate a Web Form from looking into a database table. We have to be able to generate staff surveys - our company is quite big, and occasionally the form fields change. Ultimately this means one of our dev's have to go and modify some ASP.NET webfor...

changing DTS(data transformation service) options in sql server 2000 through SQL Query Analyzer

How do i change DTS options in sql server 2000 through SQL Query Analyzer? Such options are source, destination, transformation columns, etc.. ...

Displaying URL's from SQL Server

I have a question about display URL's that are stored in an SQL Server database. Here is an example. I have a field in a table called "Additionalinfo" which stores this information. Company Name 1 Street Name, Suburb Ph: 0000 0000 W: http://www.google.com When I display this information on the page it displays the informatio...

how to union record from another table with only different id by "Union All"

I have 2 tables with duplicate record including 'Id' field, and I need union them. But I think [union all] is much more efficient than [union] for the reason that it need not sorting. Following is my sql: SELECT * FROM [dbo].[RealTime] UNION ALL SELECT * FROM [dbo].[Query] a WHERE NOT EXISTS(    SELECT TOP 1 1    FROM [dbo].[RealTime]...

Stored procedure question with IS_MEMBER

I have a table Users with columns ID nvarchar(4000) GroupRank int Definition nvarchar(4000) ID can be a userid (in which case groupRank is NULL), a domain group with a rank (in which case grouprank is not null) or a reserved default group called #DefaultGroup. I need a stored procedure that will: If ID=SYSTEM_USER, return that Defin...

Inserting NULL in an nvarchar fails in MSAccess

I'm experiencing something a bit strange. I have a table on SQL Server 2008, say StockEvent that contains a Description field defined as nVarchar(MAX). The field is set to be Nullable, has no default value and no index on it. That table is linked into an Access 2007 application, but if I explicitly insert a NULL into the field, I'm sys...

database view performance issue

Hello everyone, I am using SQL Server 2008 and I have two tables which are of the same schema and I create a view which union the content of the two tables to provide a single view of "table" to external access. One of the table is read only and the other table contains bulk insert/delete operation (on the other table, I will use bulk ...

How to improve 'Incorrect syntax near the keyword 'select'.'

this query give me 'Incorrect syntax near the keyword 'select'.' look please below bold character area. declare @date1 smalldatetime, @date2 smalldatetime, @page nvarchar(100) ,@sum int select @date1='2009-06-06',@date2='2009-06-13',@page='Tüm Sayfalar' set @sum = select Sum(t.[VISITINGCOUNT]) from ( select count(page) as [VISIT...

SQL Server 2008 Express connection problems

Hi, I'm testing a C# application on SQL Server 2008. It used to work perfectly on 2005 Express edition, but now it seems to take ages to open connections to 2008 Express (default install, using sharedmem protocol). Also, repeteadly I got errors of connection problems. Any idea? ...