sql-server

SQL Server Query to bring groupwise multiplication

When a table having following value Say TableA **Grp Value** Grp1 2 Grp1 5 Grp1 3 Grp2 3 Grp2 -5 Grp2 -2 Grp3 4 Grp3 0 Grp3 1 Grp4 -2 Grp4 -4 Grp5 7 Grp5 NULL Grp6 NULL Grp6 NULL Grp7 -1 Grp7 ...

SQL Server: should I use information_schema tables over sys tables?

In SQL Server there is two schemas for metadata: INFORMATION_SCHEMA SYS I have heard that INFORMATION_SCHEMA tables are based on ANSI standard. When developing e.g. stored procedures, should it be wise to use INFORMATION_SCHEMA tables over sys tables? ...

sql server 2005 replication via remote IP

I want to push subscriber using IP address except server name. How can do this? Please give me an example or reference. ...

Best practices for database development in Visual Studio 2010?

I'm starting a new, large server based project using .Net 4 and Visual Studio 2010. I've done this many times before (with various versions), but I've never found a good way to maintain my database. There's been a lot of new technologies in the past few years to make this easier. However, there is one thing I haven't found: A technology/...

Sorting on GUID SQL Server 2008

Hello What is the best way to sort records on Guid. Below never gives right results. With UIDs As (-- Select ID = 1, UID = NEWID() Union Select ID = 2, UID = NEWID() Union Select ID = 3, UID = NEWID() Union Select ID = 4, UID = NEWID() Union Select ID = 5, UID = NEW...

SQL query help, conditional join

Hi guys, SQL newbie here :) Here are my tables if anyone's interested. AHH, cant post image yet http://img832.imageshack.us/img832/442/72098588.jpg What I'm trying to do is query the tblPatientStats table within a date interval (@StartDate, @EndDate) and group them accordingly in a data grid on winforms. So each row in tblPatientSta...

Is It Possible to Add SQL Reporting Service to SQL Server 2008 Express?

I joined a windows host who runs SQL Server 2008 Express (Negative Surprise)! I think this is wrong since a host should expect some medium companies join them so they should put at least standard version. I don't know much about dba, but this is my suggestion. Am i right? OK! Here is my question, the host has SQL Reporting Service as an...

How to select a column in SQL Server with a special character in the column name?

I have a table contain the '%' in the column title, and this cause problem when I do the select statement on that column (Find below for more details). Does anyone know how can I select that column by not keeping the original column title? Example: Table1 name ref_no tot_sales %Phone ------------------------------- Alan 1 1 ...

changing SQL Server database collation

Is it possible to change collation for all objects under the database? For example, if I change the database collation, it should change all the objects (tables,procs,etc.) related to that database. ...

Best data type for storing strings in SQL Server?

What's the best data type to be used when storing strings, like a first name? I've seen varchar and nvarchar both used. Which one is better? Does it matter? I've also heard that the best length to use is 255, but I don't know why. Is there a specific length that is preferred for strings? ...

Using SQL Server Replication for SQL Server 2005 and 2008

I have an ASP.NET application that uses replication, and uses the RMO DLLs to do this. I initially built the application against the 2005 version of the DLLs and have it running successfully against SQL Server 2005. However, when I try running it against SQL Server 2008 it doesn't work. Initially I didn't deploy the Microsoft.SqlServer....

SQL Server version of Oracle's CONNECT BY in LINQ to show hierachy

I have successfully simulated an Oracle CONNECT BY statement in SQL Server 2008 by following these 2 previous answers here and here and adjusting to get the results I need. But how do I do this in LINQ? Here is an example of what I am doing using a dummy database: CREATE TABLE Employee( EmployeeID INT IDENTITY(1,1) PRIMARY KEY, Depar...

Installer App Asp.net 4.0 Cassini SQL Express

Hi, We have built an ASP.NET application in 4.0 (we can change it to 3.5 if necessary) with a SQL Server database. I am looking to create an installation package (exe or msi) so that I can provide this file to my clients and they can install it on all of their laptops. This asp.net application will be running on laptops that don't hav...

Does Indexing a View in Sql Server 2008 actually duplicate the original data?

Hi folks, If i create an Indexed View (in Sql Server 2008), does this mean i copy all required the data from the source tables into a separate new table? Or are only some tiny pointers/indexes saved, to represent this view? ...

How to delete rows in tables that contain foreign keys to other tables

Suppose there is a main table containing a primary key and there is another table which contains a foreign key to this main table. So if we delete the row of main table it will delete the child table also. How do I write this query? ...

how to check uniqueness (non duplication) of a post in an rss feed

when retrieving and caching/saving (in a database) some posts from an rss feed, how to determine that: it is the same post (example: when some typos are fixed in the feed or if the title changes, the date changes, etc...) find feeds that talk about the same topic (example: same story from different sources) are there any best practic...

Unable to generate my report

I have to generate a report in this format: staffcode Name dateintime dateoutime duration for example: Staffcode Name 01-08-2010intime 01-08-20100uttime 01-08-2010duration 1001 Amit 09:00 18:30 09:30 In sql server management studio for 5 days i have ...

Posting data to a web page from SQL Server trigger

Is it possible to post data from a SQL Server trigger to an external web page via POST or GET method? For example, I want to post value of a field "BOOKID" on INSERT trigger to http://www.example.com/newbook.php?id=XXXXX ...

SQL Server: how to use the same procedure in different instances?

I have a stored procedure in a test instance of a sql server (named sql2008test\sql2008_test) and it is located in one database. I would like to use this procedure also in production instance (named sql2008prod\sql2008_prod). Should I copy this procedure into this prod instance or can I modify my procedure somehow to query data from prod...

Which are the problems in creating and dropping a linked server just for executing a remote query?

I need to retrieve some data from a remote database, it is a kind of "updates manager", so my application will connect to that remote server to check if there are new updates. I use a webserver for doing the "handshake and validation" work, but then I connect directly to a remote sql server to retrieve the data. The webserver will ret...