sql-server

SQL SELECT WHERE Trouble any ideas helpful

I have two tables parent and child (related as such on PK/FK GUID) Child has a Timestamp (the record creation date/time). What I want to do is get only the most recent child record AND the parent record, FOR EACH parent record. SELECT dbo_Parents.ParentName, dbo_ChildEntry.CountPropertys, dbo_ChildEntry.DateTimeStamp FR...

SQL Server SMO TransferData() keeps failing

I am using the TransferData method of the transfer class in SQL Server SMO. I have the call running on Windows XP, running SQL Server 2008 SP1, trying to transfer a table from SQL Server 2000 on another server to the XP machine. They both use the same SQL username and password. I have tested using the Import/Export Wizard and it ran fin...

Web Service Out of Memory Exception while filling ADO.Net DataSet

1) ClientApp makes async call to ASP.Net 2.0 WebService 2) Web service calls SQL Server 2005 stored procedure 3) Stored procedure returns data output, 150MB table Out of Memory Exception is thrown by DataAdapter.Fill(...) while trying to allocate more memory for new rows. IIS Application Pool does not have any Max Memory restrictions o...

How to verify whether two SQL Server databases contain equal data?

Given two MS SQL databases which are known to have identical schemas, how should I tell whether they contain identical copies of the data? I'm using MS SQL Server 2008 Express, and coding in C# and v2.0 of the .Net framework, using ADO.NET APIs. The two database instances are both on the same SQL server. Background: I've written softwa...

Comments in SSRS Report Expressions

I'm using some complicated expressions in Reporting Services to control the value, format etc of data in a report (see MSDN). Is it possible to insert code comments into these expressions, and if so, what is the syntax? By code comments I mean something like: // single line comment /* or multi line comment */ ...

SQL Server : Creating an index on a table variable

Can you create a index on a table variable in SQL Server 2000? i.e. DECLARE @TEMPTABLE TABLE ( [ID] [int] NOT NULL PRIMARY KEY ,[Name] [nvarchar] (255) COLLATE DATABASE_DEFAULT NULL ) Can I create a index on Name? ...

Modify xml element name in SQL Server

I want to change element name with following statement: SET @myDoc.modify('replace value of (/CustomerInfo)[1] with "Customer"') from <CustomerInfo>     <ID>1</ID> </CustomerInfo> to <Customer>     <ID>1</ID> </Customer> But failed. So how can i change it just in sql ? ...

How do I execute a stored procedure once for each row returned by query?

I have a stored procedure that alters user data in a certain way. I pass it user_id and it does it's thing. I want to run a query on a table and then for each user_id I find run the stored procedure once on that user_id How would I write query for this? SQL SERVER ...

What happened with SQL English query?

SQL Server 2000 was deployed with English Query. At that time, I was young and new to SQL so I skipped that chapter. Now after years, there is again an idea of making a logical program which can understand simple user questions. Is there any alternative to that? Where is English Query now? Best regards, Admir ...

How to check the integrity of the storedprocedures

Hi, We have a large database containing a lot of stored procedures. Now we are updating our database but some stored procedures still use the old structure. We've found most of them using 'sp_depends' but some sp's slipped through. I was wondering if there isn't a way to check all stored procedures. If they call for a column that doesn...

how to get top ten result in sql?

This delow query give me some error: declare @date1 nvarchar(100) , @date2 nvarchar(100) select @date1='2009-04-20', @date2='2009-05-20' select top 10 t.VisitingCount , t.Page from ( select Count(Page) as VisitingCount,Page from scr_SecuristLog where Date between @date1 and @date2 ...

List of unique strings in database table using Linq?

I have a "Tickets" table with somewhat following structure (removed unnecessary columns) int | string | int | ID | Window | Count | ------------------------ 0 | Internet | 10 | 1 | Phone | 20 | 2 | Fax | 15 | 3 | Fax | 10 | 4 | Internet | 5 | . | . | . | . | . | . ...

SQL Server: Extract Table Meta-Data (description, fields and their data types)

I am trying to find a way to extract information about my tables in SQL Server (2008). The data I need needs to include the description of the table (filled from the Description property in the Properties Window), a list of fields of that table and their respective data types. Is there any way I can extract such meta-data? I presume I ...

SQL Server: Writing a proper Table Description

I am, for the first time, writing descriptions for my SQL Server tables (from the Description field in the Properties Window), and I started thinking about what to exactly write in such a field. For examples, some tables are self-explanatory according to their titles...like a table called Albums in a "Music System". What description wo...

How to find sql2000 databases info using Sqlserver SMO

Hi How to Find sqlserver2000 databases info using SQLSERVER-SMO ...

Normalizing data

I need to update the managerid field with the related employeeid. CREATE TABLE Employee( EmployeeID Int Primary Key Identity, Name Varchar(50), ManagerID INT default 0, ManagerName Varchar(50) default '' ) INSERT INTO Employee(Name,ManagerName) VALUES('Dilbert','Boss') INSERT INTO Employee(Name,ManagerName) VALUES('Boss','Dogbert') INSE...

SQL Server Server query - Count distinct DateTime field

Supposing we have the following records in an SQL Server table. Date 19/5/2009 12:00:00 pm 19/5/2009 12:15:22 pm 20/5/2009 11:38:00 am What is the SQL syntax for getting something like this one? Date Count 19/5/2009 2 20/5/2009 1 ...

How do I select a row that appears in a text list?

I have a SqlServer customer table customer (first_name, last_name, home_phone, cell_phone) and a text file list of phone numbers like 9876543210, 4564561234, 1231231234, 1234567890, The phone numbers in the customer table are stored in the format +1dddddddddd: where dddddddddd is the phone number. How can I find all the customer ...

SQL Server 2008 Mixed Mixed Mode Security?

We are setting up a SQL Server 2008 Standard edition on a Web Server for the first time. We normally have our SQL Server on our local Intranet and only use windows authentication. What is the best practise authentication mode for a web server? Can I use Mixed mode without any security worries? Thanks! ...

What's the best way to update data in a table while it's in use without locking the table?

I have a table in a SQL Server 2005 Database that is used a lot. It has our product on hand availability information. We get updates every hour from our warehouse and for the past few years we've been running a routine that truncates the table and updates the information. This only takes a few seconds and has not been a problem, until no...