sql-server

How to diagnose ArgumentOutOfRangeException on SqlDbType?

We have some customers using our .NET 2.0 thick-client app that experience strange, intermittent errors reading data from a SQL 2000 SP4 Server, where the actions succeeded just moments earlier. We have some customers using SQL 2000 (and many using 2005) where these errors do not occur. One thing I notice is that the app in our testing ...

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? ...

How do I access the .NET TimeZoneInfo class from SQL Server 2005?

The TimeZoneInfo class has a Host Protection Attribute of MayLeakOnAbort. This seems to prevent me accessing it from the SQL Server CLR. But is there a workaround? ...

How do I dynamically set the table and field name in an update query?

I'd like to loop over a list of tables. For each table, I'd like to run an update query. Psuedo code: ArrayOfTablesObjects = {['tablename1','fieldname1'],['tablename2','fieldname2']......} foreach @tablename in ArrayOfTablesObjects UPDATE @tablename SET @fieldname = 'xyz' WHERE @fieldname = '123' end foreach ...

Adding a non-empty constraint to Email field

I have a varchar email field in my table. I can't figure out the sytnax to add a constraint that ensures a non-empty value cannot be inserted. I"m not talking about not null, I'm talking not empty here. ...

Using TimeZones on website using ASP.Net 3.5 / SQL Server 2005

I am trying to determine, how I should implement local time in a web-app. All users are logged in, there are no anonymous users. They will need to see all time-values in their local time. Is this how it should be done? All DateTime values are saved as UTC-time in database Each user has a UTC-Offset value stored in his profile When dis...

Strange result return from sql server

Hello everybody, I am working on my project and having strange result with asp.net C# and stored procedure that returns scalar variable. In short, I am trying to return user name, however I get only the first letter from the name, which is strange. I went trough the code couple dozen of times; however i still cannot find the error. I w...

Access my SQL server from home in Server Explorer

On my LAN at work, I have SQL Server 2005 running on one machine and my developer machine (a different machine) has VS2008 on it and I can access the SQL Server from Server Explorer in Visual Studio using the computer name and the local lan domain name i.e.: mspc2.ourcompany.local So, I know it is all up and running well, and I can see ...

NHibernate won't persist DateTime SqlDateTime overflow

I am working on an ASP.NET MVC project with NHibernate as the backend and am having some trouble getting some dates to write back to my SQL Server database tables. These date fields are NOT nullable, so the many answers here about how to setup nullable datetimes have not helped. Basically when I try to save the entity which has a DateA...

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 ...

Process rdl/rdlc report files without SSRS?

Is there any way to render and export an rdl file within a batch process without using SSRS? I don't want the overhead of SSRS (IIS + database) and instead want to handle this within my own batch/scheduling service. Thanks ...

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...

ASP.NET 3.5 and SQL Server 2008

I'm new to ASP.NET and to SQL Server. I'm from the PHP/MySQL world, so I'm pretty confused with this stuff. I need help because I'm trying to make a simple blog as a first serious exercise. I can't figure out how to connect to my sql server from my c# code. my sql server is on the same machine as IIS. When i use SQL Server Management Stu...

Best tool to convert my SQL Server database to Oracle

I need a tool that will convert my SQL Server database to Oracle 10. A have found many of them but which is best? ...

Sql server 2008 log will not truncate. Driving me CRAZY!

I consider myself a very experienced SQL person. But I'm and failing to do these two things: Reduce the size of the allocated log. Truncate the log. DBCC sqlperf(logspace) returns: Database Name Log Size (MB) Log Space Used (%) Status ByBox 1964.25 30.0657 0 The following does not work with SQL 2008 DUMP TRANSACTION ByBo...

use of variable in from clause in select statement

Can I write a select statement where the from clause has a scalar variable which contains table name ? Actually I want to write a store procedure that will take table name as input and display percentage of nulls in that table. thanks ...

Clustered index insert performance on not-so-unique column?

In your experience, at about how many records does insert performance become intolerable when using a clustered index on not-typically-unique columns? A good example I can think of would be the comments table for stack overflow. Do you think that insert performance would be acceptable if the comments table had a clustered index on their...

Macros in SQL Server Management Studio

Is there any way to implement text editing macros in SSMS? I would, e.g. like to convert the the code as shown below, but with a key-press, not a long-winded regex search and replace. This: INSERT INTO [TABLE] ([fieldOne] ,[fieldTwo]) VALUES (<fieldOne, datetime,> ,<fieldTwo, real(24,0)) Must become this: INSE...

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...