sql-server

Web Services: Accessing Session State from Host Client to Service Proxy

How can I access the Session State created from a Client(Website) to my Web Service Proxy site? Services Interface Proxy public class SessionService : System.Web.Services.WebService { [WebMethod(EnableSession=true)] public string GetSession(string key) { return HttpContext.Current.Session[key].ToString(); } } Website hostin...

How come I can't see rows in sysobjects for objects that I know exist?

I am a member only of the db_datareader role on a database, and I cannot see rows in sysobjects for stored procedures that I know exist. Additionally, in SQL Server Managedemnt Studio, expanding the Programmability -> Stored Procedures node in Object Explorer does not show any stored procedures. Is this due to insufficient permissions?...

SQL Server lat;lng varchar split procedure to use as Lat and Lng for speed Searching

Can someone help me using a stored procedure or function to passing my stored varchar lat;lng in table to individuals fields as float as Lat and Lng to use in radius search. lanlng in Table 33.0000;15.222222 Thanks ...

User-friendly tools for retrieving data from a SQL Server database

We have several SQL Server databases containing measurements from generators that we build. However, this useful data is only accessible to a few engineers since most are unfamiliar with SQL (including me). Are there any tools would allow an engineer to extract chosen subsets of the data in order to analyze it in Excel or another environ...

SQL - Order after filtering

How can I order the data and then filter it in TSQL (SQL Server)? I've tried something like this: SELECT [Job].*, ROW_NUMBER() OVER (ORDER BY [Job].[Date]) AS RowNum FROM [Job] ORDER BY Rank WHERE RowNum >= @Start AND RowNum < @End Doesn't work. I also tried to use a subquery, which throws: The ORDER BY clause is invalid ...

What are the pros and cons of having history tables?

WHAT is the better practice?: Keep history records in a separate history table Keep history records in the active table with different status? In my opinion I rather to keep a separate table to avoid creating one huge table with duplicate records which may cause unwanted lag time when querying the table. ...

Help debugging sql query: where do I have an extra ( or )?

I am getting 2 errors: 1) Incorrect syntax near keyword union 2) Incorrect syntax near ')' Here is the query: select count(*) as numUsers, count(r.cabGroupId) as numCompanies from (select r.newUserId, r.groupId from reportaccesslogs r full outer myTable d on r.num = d.num where (r.r...

Define a custom delete rule for Parent-Child relationships

I'm trying to create a custom delete rule on a relationship between a parent and a child table. What I'd like to do is to apply cascade delete on the child if the child's column 'IsActive' is set to false and to apply 'NoAction' rule if this column is set to true. How can I do this? ...

How do I find which indexes are being used and what query is using the index?

I am using SQL Server 2008. I have tables on which there are duplicate indexes (basically indexes with same definition). I wanted to know if its possible to find out which queries are using these indexes? I don't know why the duplicate indexes were created in the first place. So before removing them, I want to identify any queries which ...

Need to move SQL Server 2005 Table storing Lat;Lng as varchar to Spatial ?

I have read some articles about using spatial optimized tables. Actually I use stored latitude and longitude as varchar comma-separated (lat;lng). Could you suggest the best way to perform this change and enumerate the advantages. It's really necessary for a large project or only move to SQL Server 2008? thanks. ...

Log table with millions of rows. Now, what?

I have a Log table with millions of rows. I'm thinking about separating the data into multiple tables (i.e. LoginHistory, ExceptionHistroy, PaymentProcessingHistory, etc.) What is the term used when taking a large table with many rows (not Columns) and creating multiple tables? My current Log table schema resembles: LogID, LogMessage, L...

SQL Server Cascading

I am making a website where users can post 'Posts' and then users can 'Comment' on these posts. I have a database with 3 tables. One contains User Information, one contains Post Information and the final one contains Comment Information. I want to set up rules so that if a User is deleted, all of their posts and comments are deleted, an...

Does SQL Server 2005 Log Shipping replicate changes to the master database schema and permissions?

In a SQL Server 2005 database that is replicated using log shipping, will changes to the following be automatically reflected in the replicated database? Tables Stored Procedures Views Functions Object-level permissions Database roles ...

Stop SQL Server - using C#

How can I use C# to stop SQL Server? ...

Is there a way to only return a PART of a compound primary key?

I have a SQL table with a compound key, ID (int, autogenerated) and TaxpayerID (varchar, user enters it). When the user registers, they enter a taxpayer ID & the taxpayer ID combined with the ID make a Primary Key. Normally after entering a record, I'd return used @@Identity and return it to a Integer variable in my .NET application. H...

Help debugging sql query: where do I have an extra ( or )?

This query works: SELECT u.UserId, u.GroupId, u.username, gp.PreferenceId, gp.Properties, gp.Override FROM dbo.UserTable u Inner JOIN dbo.GroupPreferences gp ON gp.GroupID = u.GroupId WHERE (u.UserName = 'myUserId') But the same query inside another query doesn't. I ge...

How can I handle a web application that connects to many SQL Server databases?

I am building an ASP.NET web application that will use SQL Server for data storage. I am inheriting an existing structure and I am not able to modify it very much. The people who use this application are individual companies who have paid to use the application. Each company has about 5 or 10 people who will use the application. Ther...

Select all records created or modified after a specific date in all tables in a SQL Server db

I would like a list of all new or modified records created after a specific date in all tables in a SQL Server database. I am using SQL Server 2005 and ssms. Is there a way to do this with one query, or some other tool? How could I do this for one table? ...

Retrieving SQL Relationships as a comma delimited string

Hello, I have a SQL Server 2005 database with two tables: Order, LineItem. Each LineItem has a field called LineItemID and OrderID. I have a query that is getting all of the Order records in my database. With each Order record, I would like to retrieve a comma delimited list of LineItemIDs associated with the Order. Is there a way to d...

To compare column name with the corresponding values in Microsoft SQL Server

Hi all I have a function which takes two parameter type and value. According to the type it will search the corresponding table whether the value exist or not and return a boolean value. Now I have created a table with the type as columns. I want to pass the column name and its corresponding values to be passed to the function. For exa...