sql-server

Decimal places not rounding correctly - is this a LINQ to SQL bug?

My database field (sql server 2005) is defined with numeric(15,2). The LINQ 2 SQL generated property is [Column(Storage="_My_Property_Name", DbType="Decimal(15,2)", UpdateCheck=UpdateCheck.Never)] public System.Nullable<decimal> My_Property_Name { get { return this._My_Property_Name; } ...

Delete from tablename takes abnormally long

I've a table in sql server 2005 with a chaild table that has millions of records in it. Whenever I issue a delete command even with a where clause, it takes abnormally long to execute it. Is it bacause the size of the child table that is causing this delay? What are the ways to make the delete query faster? thanks, sweta. ...

Retrieving users for specific SQL Server databases

Hi there: I have a few SQL Server databases (all in one server), containing their own set of users. Now I'm trying to design a small application that would query those users and then display them in a report (TBD). I've looked over online how to do this, however I didn't find any. Is it possible in SQL Server to retrieve all the users ...

What's the best way to allow queries/views to see how tables looked in the past based on a datetime stamp in SQL Server 2008?

Scenario: We have a great deal of server environmental information (names, IPs, roles, firewall ports, etc.). Currently it's stored in a big Excel workbook on a SharePoint, which trivially allows for side-by-side comparisons of past versions of the data with current, for example. we're planning to move it into a SQL Server 2008 databa...

Save data in bulk.

I have a window having multiple tabs. Each tab having different grids. I want to save all changes on any tab on any grid in bulk. I mean I have one save button which will save all changes in any grid on any tab. I think DataTables will work fine here. Can you suggest me that it is good to use DataTables to ADD/Edit data and save data i...

Transforming nvarchar day duration setting into datetime

I have a SQL Server function which converts a nvarchar day duration setting into a datetime value. The day duration format is >days<.>hours<:>minutes<, for instance 1.2:00 for one day and two hours. The format of the day duration setting can not be changed, and we can be sure that all data is correctly formatted and present. Giving th...

How can I order by Greek Letters and Normal Letters in SQL Server?

I have a mix of greek and normal words and now the order of these is that the normal words comes first and then all the greek words. I want them to get mixed in the order so beta in greek is the same as B. How can I make this ORDER BY in SQL Server? ...

Counting number of children in hierarchical SQL data

Hello, for a simple data structure such as so: ID parentID Text Price 1 Root 2 1 Flowers 3 1 Electro 4 2 Rose 10 5 2 Violet 5 6 4 Red Rose 12 7 3 Television 100 8 3 Radio 70 9 8 ...

Stored procedure in SQL Server (order by desc)?

I have a stored procedure that will give the latest records i.e., order by added date this is my procedure.... select distinct top 5 videos.videoid,videos.videotitle,videos.videoname, convert(varchar,videos.posteddate,106) as posteddate,videos.approvedstatus, videos.videoimage,(ISNULL(videos.views,0.0)) as [views],videos.privac...

Is it good idea to build xml api based on for xml in SQL Server 2005?

One of my coworkers is going to build api directly from database. He wants to return xml for queries. Is really good idea? We have to build api for our partners and we are looking for good architectural approach. We have few milions of products, reviews and so on. Some partners will take 1000 products others would like to copy almost ...

Best database design approach to join complex data to ASP.Net Membership tables

I'm looking to use a slightly modified ASP.Net Membership Provider to handle the standard user account creation/authentication/etc in a website. We have a fair amount of legacy data that I need to migrate in order to provide continuity with our existing users' saved information (like order history, wishlist, etc). [NOTE: We have to mi...

SQL Server 2005 replication trigers - how to?

Hi, I need to run the replication of one table in SQL Server 2005. Replication should be one way. From 1 master server to many children servers. I thougt about snapshot replication, but I don't want to schedule it only for example every hour/minute ect. (I know how to do this.) but ALSO triggered it evry time new data appears in master...

How do you get notification of schema changes in your Sql Server database via email?

We deploy multiple instances of multiple databases to multiple sites. These sites all have their own DBAs. Here at head office we would like to monitor all the satellite databases and get a notification when any of the schemas change (table structures, stored procs, views etc). Is there any tool available that can perform this function...

How to combine two queries as a single result set in SQL for Categories - Subcategories?

I have the following function: CREATE FUNCTION [dbo].[ListStockBySubCategory] ( @CategoryID varchar(10), @SubCategoryID varchar(10), @startRowIndex int, @maximumRows int ) RETURNS TABLE AS RETURN ( SELECT ISBN FROM ( SELECT ISBN, ROW_NUMBER() OVER(AddedDate DESC) AS RowNum FROM ( SELECT DISTINCT RTRIM(...

VB.NET - Direct Database Access

I'm making a VB.NET application with an SQL Server 2005 in the background. Naturally the user can not edit the database directly but will use a number of UI features to be able to add and modify the data. However, there are a few tables that should be easily accessible from the admin interface such as specific information about a vendor...

Getting a Return Value in C# asp.net from a stored procedure (syntax issue)

I am having issues trying to get the syntax correct for my C# 2008 asp.net code. I need to get a return value (Select @@Identity) from my stored procedure My C# code is: SqlConnection conn = new SqlConnection(strConn); string sql = "usp_ClientProfile_Header"; SqlCommand cmdHeader = new SqlCommand(sql, conn); ...

Multiple results for one field in a joined SQL query

I'm not sure if this is possible from with a SQL query, but I'll give it a go. I'm developing a SharePoint web part in C# that connects to a SQL database and runs a query, then databinds that result set to a gridview. It's working fine, but I have a small snag. For the most part, my query will return exactly one result for every field. ...

How to schedule a stored procedure?

How do I schedule a stored procedure in Sql Server 2005 that it runs once at the start of every month (and on database startup)? ...

Generating order statistics grouped by order total

Hopefully I can explain this correctly. I have a table of line orders (each line order consists of quantity of item and the price, there are other fields but I left those out.) table 'orderitems': orderid | quantity | price 1 | 1 | 1.5000 1 | 2 | 3.22 2 | 1 | 9.99 3 | 4 | 0.44 3 ...

return parent and child data using FOR XML in a stored proc

If I have a parent table and a child table where there can be one parent to many children, how can I go about returning the following xml from a stored procedure in a stored procedure? <Parents> <Parent> <ID>Integer</ID> <Children> <Child> <ID>Integer</ID> <Text>String</Text> ...