sql-server-2005

[Managed UDF/ SqlServer2005 ] How to force dbo schema name?

I'm using "SQL SERVER PROJECT" in VS 2008 to create UDF in C# Then I'm using DEPLOY command to publish DLL into MS SQL server 2005 All works well except all created UDFs are owned by me (as user) But I wanted to keep dbo schema (eg: dbo.UDF_TEST - not jonny.UDF_TEST) Any idea how to manage thar? ...

How to map uint in NHibernate with SQL Server 2005

I have a property of type uint on my entity. Something like: public class Enity { public uint Count {get;set;} } When I try to persist that into the SQL Server 2005 database, I get an exception Dialect does not support DbType.UInt32 What would be the easiest way to workaround this. I could for example store it as long in the ...

From SQL Server, how can I export to Excel with the column headers?

I have a query that has approx 20 columns and I would like to export this to an Excel file with the column headers. I thought this would be easy to figure out but no luck! I searched the web and found one suggestion that did not end up working so I am stuck. Anyone have any working ideas? Thanks, ...

SQL 2005 instance won't work with DNS

Basically I have a sql 2005 standard server with a named instance installed (server/instance1). I also have created a DNS entry (dnsDBServer) that points to the ip address of the sql server. A web application we have can connect using the following methods (ipaddress/instance1, server/instance1) but cannot connect using the dnsDBServer...

SQL Server 2005 - Queries going into suspended state immediately

I'm having a problem with an ad-hoc query that manages a fairly high amount of data. Upon executing the query, the status immediately goes into suspended state. It will stay suspended for around 25 minutes and then complete execution. I have a mirror environment with SQL2K and the same query executes in around 2 minutes and never goes i...

How to find out user name and machine name to access to SQL server

My work company has a MSSQL server 2005. I have two questions about finding out current log user and any way to send out a warning message: First question is if there is any T-SQL or SP available to find out current login user name and machine name. If the user is using SQL server sa name to remotely access to SQL server, is there any w...

SQL 2000 or clause not working in SQL2005

Could anyone help me understand why the following query works fine in SQL 2000 and not in SQL 2005 In SQL 2005 it errors out "The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value" DECLARE @Table table(date varchar(6),code char(1)) INSERT INTO @Table select '010209','N' INSERT INTO ...

help with T-SQL on SQL Server 2005

Hi there, I have a T-SQL that works below: SELECT WP_VTDID AS UTIL_VTDID, (SELECT COUNT(WP_ENGINE) FROM WAYPOINTS WHERE (WP_ENGINE = 1) AND (WP_SPEED > 0) AND WP_VTDID='L083') AS UTIL_RUN, (SELECT COUNT(WP_ENGINE) FROM WAYPOINTS WHERE (WP_ENGINE = 1) AND (WP_SPEED = 0) AND WP_VTDID='L083') AS UTIL_IDLE, (SELECT COUNT(WP_ENGINE) FROM ...

Hibernate Query runs slow in the system, but fast when run directly.

I have a problem similar to the on in this weeks podcast. We have a Java application using hibernate with Sql Server 2005. Hibernate is generating a Query for us that is taking nearly 20 minutes to complete. If we take the same query using show_sql and replace the questions marks with constant value the answer is returned immediately....

Dynamically create temp table based on resultset from SP

I have a SP that calls another SP and the resultset needs to be filtered to only the columns that I am interested in. DECLARE @myTable TABLE ( Field1 INT, Field2 INT, Field3 INT ) --If someSP returns say 30 params and I need only 3 params, I don't want to declare all 30 in my temp table @myTable INSERT INTO @myTable (Field1, Fie...

Performance questions for SQL Cache Dependency

I'm working on a project where we are thinking of using SQLCacheDependency with SQL Server 2005/2008 and we are wondering how this will affect the performance of the system. So we are wondering about the following questions Can the number of SQLCacheDependency objects (query notifications) have negative effect on SQL Server performance...

Modify master.dbo.syslanguages or insert new language

In my application we have to call SET DATEFORMAT YMD before each and every operation. In the master.dbo.syslanguages in entry for my language (polish, lcid=1045) there is dmy format. So is there any way I could change this entry or create a new language that will be like old one, but with changed DATEFORMAT? ...

Get question with newest answer SQL Query

Hi, I have a model like: Question - Id - CreatedOn Answer - Id - CreatedOn - QuestionID No I want to get the first question with the newest answer. I am using SQL Server 2005. Thanks, Chris ...

Is it possible to use a Case statement in a sql From clause

Is it possible to use a Case statement in a sql From clause. For example, I'm trying something like: SELECT Md5 FROM CASE WHEN @ClientType = 'Employee' THEN @Source = 'HR' WHEN @ClientType = 'Member' THEN @Source = 'Other' END CASE WHERE Current = 2; Edit: Using SQL 2005 ...

How to get history of logins to MS SQL Server 2005

Is there any system view or tables available to get history logins to MS SQL server 2005? If it were available, I would like to use TSQL to get information about login information for a datetime range. I have a scheduled job failed one day because of a thread deadlock exception on a table accessed by a stored procedure. By checking log...

Making a SETUP file

I have a VB project that runs on SQL SERVER 2005, while making the setup file for it, how do I include the DB? ...

Algorithm for the following problem

You require an algorithm to read in one customer's account balance at the begining of the month, a total of all withdrawals for the month, and a total of all deposits made during the month. A federal tax charge of 1% is applied to all transactions made during the month. The program is to calculate the account balance at end of the month ...

How to get Windows Log-in User Name for a SQL Log in User

By using sp_who2 I can get a list of current log-in users and machine names. Some users are using SQL Server log-in user name such as sa. Is there any way I can get the windows log-in user name for the SQL log-in users? If there is no way to get Windows log-in users from the machine names, can I use WMI class or C# to get find out the W...

How can I unlock the sa account on SQL SERVER 2005?

We have moved a database from SQL 2000 to a new SQL 2005 that is used with an intranet page to display and update data. We are now unable to login using the sa account as the settings for the page used the old login password and appears to have locked the sa account. I guess using the sa account for this page was not such a great idea b...

Updateable view in mssql with multiple tables and computed values

Huge database in mssql2005 with big codebase depending on the structure of this database. I have about 10 similar tables they all contain either the file name or the full path to the file. The full path is always dependent on the item id so it doesn't make sense to store it in the database. Getting useful data out of these tables goes a...