sql-server

SQL 2005 Job Execution: TCP/IP vs Named Pipes

Good day, I've got 2 jobs on a SQL 2005 instance that run one identical T-SQL step. That step executes a cross server query to a remote 2005 instance. The only difference between the jobs is one is owned by a sysadmin and one is not. The job that is owned by a sysadmin executes under the Agent's startup account and the one that is not...

MS SQL Server optimizer and varying table and field aliases

We have a lot of quieries for which we append a random alias at the end of field and table names (due to a custom ORM implementation that might be hard to change). The queries are like the following (though substantially more complex, most of the time): SELECT fooA.field1 as field1B, fooA.field2 as field1C FROM foo as fooA ...

How to determine the number visible children in an hierarchical report?

I am using SQL Server Reporting Services 2008 to create a report. A table in this report displays hierarchical data, using a ID and ParentID field in the data. Each data row has an ID field and a ParentID field, where the ParentID points to the ID of the row that is its parent. Displaying this hierarchically is no problem, but now I wa...

SQl Server Express 2005 - updating 2 tables and atomicity?

Hi all, First off, I want to start by saying I am not an SQL programmer (I'm a C++/Delphi guy), so some of my questions might be really obvious. So pardon my ignorance :o) I've been charged with writing a script that will update certain tables in a database based on the contents of a CSV file. I have it working it would seem, but I am ...

If a Column is a Foreign Key does it need an Index?

I have created indexes on many of my columns in my tables. Many of these columns are foreign keys as well. Can I safely delete the indexes on the columns that are foreign keys? ...

Installing SQL Server Express 2008 and IIS on same machine

There are a couple of questions on SO regarding the pros and (mostly) cons of having SQL Server and IIS running on the same machine: http://stackoverflow.com/questions/274846/should-sql-server-be-on-the-same-machine-as-your-iis-installation http://stackoverflow.com/questions/1401834/when-can-i-host-iis-and-sql-server-on-the-same-machin...

sql server express - date format

Hi, In a sql server 2005 table I have a date column in dd/mm/yyyy format. But everything on sql server 2008 is yyyy-mm-dd. Where abouts can I change the format the dates that are being stored in 2008 to that of 2005? Thanks, ...

Copying Data from SQL Server 2008 to SQL Express

I would like to copy a database (tables, it’s data, stored procs & views) from SQL Server 2008 database to SQL Server Express. Is it possible? If so, would you please let me know how to do it? When I tried, it is giving some error. Please note that I have only few records in SQL Server 2008 database tables. Thanks and Regards.. Shruth...

Comparing two T-SQL tables for diffs

I have two instances of the same database. The first db represents data from today, the second data from 6 months ago. I need to find differences for a subset of entries in a specific table. For entries with ids that are in both tables, I'd like to find a way to view only the rows that aren't identical. Any ideas? Thanks ...

A simple query to check for server liveliness

In order to the determine the 'liveliness' of a remote SQL-server, I need to periodically address the server with some query. I am looking for a query which will generate minimal server work, and minimal communications overhead (both for the query and the reply). The query should work on SQL-Server 2005 and 2008 at least, and should n...

Why am I getting 'Error converting data type varchar to numeric' on a floating point number in Perl?

We are inserting values into a SQL Server 2005 database column of type NUMERIC(19,5) from Perl. As long as the absolute values are .0001 or greater, it is working. However, when the values go to the 5th decimal place, Perl starts storing them in exponential format (-9e-05 instead of -0.00009), and then we get the error "Error converting ...

The SELECT permission was denied on the object 'sysobjects', database 'mssqlsystemresource', schema 'sys'.

SETUP: SQL Server 2005 & DotNetNuke 05.01.02. This started with me trying to install a DNN Module that had "select * from dbo.sysobjects" in it's SQL scripts. That failed with the following error: The SELECT permission was denied on the object 'sysobjects', database 'mssqlsystemresource', schema 'sys'. I logged into the data...

find all duplicate values in an element attribute

I have an xml document that is stored in sql server 2005 that I want to find all duplicate values from an id attribute within an xml element. The xml looks like this: <?xml version="1.0" encoding="utf-8"?> <session sessionValue="" id="ID-1"> <data id="ID-3"> <id>d394E6FF844734CB9A5E8B17612DC050A</id> <TotalResult>803</Tot...

How to setup Forms Authentication with WindowsIdentity and SQL Server Integrated Security

Here is our current setup. We have Active Directory configured (domain named mis1) that handles all of our authentication issues. We have our web applications setup for impersonation=true so that we can have our database queries called as the user logged in. For this particular application, IIS is set to Anonymous access to we can have F...

SQL Pivot MIN( COUNT (

I have a complicated MS SQL 2005 query with a PIVOT in it... I have data like this : Data ( clients left join visits ): ClientID VisitID ServiceID 1 34 5 1 36 2 1 36 5 1 45 2 1 48 2 1 60 2 2 44 1 3 48 2 3 78 3 3 79 2 ...

(SQL) Pulling specifc data from a big list where certain dates fall within a specific quarter.

So I need to pull the e-mail addresses of members who have not logged into my site in the past 30 days. Since the site is over a few years old, we want to pull only a handful of each member from certain Quarters of the year. So for instance, there are about 800,000 people who haven't logged in within the past 30 days. So we want to pu...

What are some methods for persisting customer configurable data in a database?

I'm looking for some ideas on methods for persisting customer configurable data in a relational database (SQL Server 2000 in my case). For example let's say you have a standard order entry application where your customer enters a product they want to buy. In addition to the fields that are important to both you and the customer (item...

How do I load text files greater than the 64 kb buffersize limit?

I'm trying to load text files (.aspx, .cs, html, etc) into a sql server 2008 database. I'm able to load all files that are less than 64 kb so far. I have two questions; How do I get around the 64 kb limit, and is the method I'm using the best way to do this? Thanks for the help. Database: file_length int, file_path varchar(250), file...

How can I programmatically enumerate SQL Server 2005 named instances?

I want to programmatically enumerate the SQL Server 2005 named instances on a server. I know I should be able to do this fairly easily, but I can't for the life of me figure out how. Thanks in advance for any help! ...

Zend_Db_Select order by random, compatible in mssql / mysql

Alright here's the situation, I have an application written in the Zend_Framework, that is compatible with both MySQL and MSSQL as the backend. Now, ZF is pretty good at solving a lot of the SQL discrepancies/differences between the two languages, but I still have yet to figure this one out. The objective is to select 1 random record f...