sql-server

How do you configure a DataSource in Java to connect to MS SQL Server?

I'm trying to follow Java's JDBC tutorials to write a Java program that can connect to SQL Server 2008. I'm getting lost at the point of making a connection. The following snippet is from the tutorial: InitialContext ic = new InitialContext(); DataSource ds = ic.lookup("java:comp/env/jdbc/myDB"); Connection con = ds.getConnection(); D...

SQL Server GUID (from Active Directory) vs Int

We migrated a lot of data from our old ordering system. This system stored the users initials in our "Orders" table for each order they created. Now that we have a view that looks at active directory I would like to update those initials with the active directory objectguid (or something that references the guid). This would allow us to ...

ASP.Net - TableAdapter is returning phantom results

Hi, I have a TableAdapter that is fetching rows from an Stored Procedure. For some reason, when there are no results, the TableAdapter returns an INT with value 0 instead of NULL. The SP has NOCOUNT ON. The problem with this is that I have a ListView in the frontend with an EmptyDataTemplate, which is not being shown. When I ran the qu...

SQLServer: Why avoid Table-Valued User Defined Functions?

I have a rather huge query that is needed in several stored procedures, and I'd like to shift it into a UDF to make it easier to maintain (A view won't work, this takes in a bunch of parameters), however everyone I've ever talked to has told me that UDF's are incredibly slow. While I don't know what exactly makes them slow, I'm will to ...

How do I use ASP.NET to display video from bytes in SQL database?

I am in ASP.NET 2.0. I have uploaded a QuickTime movie to the database. It now resides as a byte array in sql server 2005. I am trying to determine how to read the bytes back out, maybe convert them to a stream and display the movie in the browser or some sort of device. I know this is broad, but can anyone even give me pointers on where...

MySql or SQL Server?

Currently I have an Asp.net website. Basically it was a prototype that showed to my school who are interested in my product. I decided to use this as my industry project that I must complete to graduate. That way if my school decides not to go with it I still can host it myself and target individuals and I complete my requirement for m...

MAX(ID) in SQL Server 2005 returning unexpected results

I have a SQL Server 2005 database with a table an ID column. When I select MAX(ID), I get only 99, but the table contains ID no's from 0 to 103. It should select 103 as max, but it returns 99. Can anyone help me out? ...

Auto Index in My SQL

Hi. I am using MySQL for my database. I have a requirement to store a list of users in the system. The user will have both first name and last name. I cannot have the first name and second name as the primary key. So I need a indexing key. But I do not want to enter the index value every time to add a new row. I want the system to ha...

Execution plan oddity after re-enabling foreign key constraint

I have a weird problem where after setting nocheck on a foreign constraint and re-enabling it, I am getting a same out-dated execution plan that was used with nocheck on. Why would SQL server generate an execution plan as if foreign constraint FKBtoA is disabled even after adding the check again with following statement? alter table ...

SQL Server - standard pattern for doing row by row operations on a table/view

I want to iterate through a table/view and then kick off some process (e.g. run a job, send an email) based on some criteria. My arbitrary constraint here is that I want to do this inside the database itself, using T-SQL on a stored proc, trigger, etc. Does this scenario require cursors, or is there some other native T-SQL row-based ...

Scheduled execution of code to conduct database operations in SQL Server

If I want to conduct some database operations on a scheduled basis, I could: Use SQL Server Agent (if SQL Server) to periodically call the stored procedure and/or execute the T-SQL Run some external process (scheduled by the operating system's task scheduler for example) which executes the database operation etc. Two questions: Wha...

Can I develop on SQL Server 2005 and deploy to SQL Server 2000?

My development under VS2008 Team Suite SP1 with SQL Sever 2005 Express SP3. One of my customer only have SQL Server 2000 License. I don't start my project yet. So I want to find a way that I can develop on SQL Server 2005 but deploy to SQL Server 2000. Thanks SO and every folks here so much. PS:I tried Database Project included in VS ...

Does NEWID() disturb the ROW ORDER of RECORDS?

Hi, This question is just for a sake of knowledge. I don't have any practical implementation of this. I have fired a query like SELECT RAND() RANDOMCOLUMNS,COL1 FROM tblY ORDER BY RANDOMCOLUMNS Output: RANDOMCOLUMNS COL1 ================================ 0.567773034904758 1 0.567773034904758 2 0.567773034904758 3 ...

Problem with deploying an application that is using sql server 2008 express

I've developed an application for my college project in Visual C# which uses SQL Server 2008 Express database. My application is desktop-based. But the problem now is deploying the application. Is it required that a SQL Server 2008 be installed on the client machine (with my tables and data inserted) or can I just have the .mdf file expo...

How do I create an If-Then-Else in T-SQL

I have some negative values coming back from a query. I would like them to just be zero. How do I write a condition in my sql query that returns zero if the value is below a certain value. sol: CASE WHEN CONVERT(float,dt.FQI53X02_101) < 1.3 THEN 0 ELSE CONVERT(float,dt.FQI53X02_101) END AS FQI53X02_101 ...

SQL Server: Can an inline table-valued UDF outperform the equivalent scalar UDF in a SELECT column list?

This question grew out of SQLServer: Why avoid Table-Valued User Defined Functions?. I began asking questions in some of the comments, and the replies to my comments moved off topic. So that you don't have to read the entire discussion: I had never heard it said that user defined functions (UDF) were slow, or to be avoided. Some links...

SQL Server 2005 - Syncing development/production databases

I've got a rather large SQL Server 2005 database that is under constant development. Every so often, I either get a new developer or need to deploy wide-scale schema changes to the production server. My main concern is deploying schema + data updates to developer machines from the "master" development copy. Is there some built-in funct...

Select most recent dates

Hello, I am trying to write a query that will return only the most recent results. The table I am pulling information from has no uniqiue columns, and contains information on rate changes so for any particular client there can be several rate changes - I only want the most recent rate change for each client. The structure is: mrmatte...

Best way to store lots of boolean columns in table.

I'm not sure if this kind of question has been asked before but I searched and could find anything. I am working on a database at the moment that has records that have lots of boolean based values stored with them, so the table structure looks something like this: ===Table=== ID <- int Name <- string Bool1 <- bool Bool2 <- bool Bool3...

Action Failed on OpenStoredProcedure action in Access Project (ADP) macro

In an Access Project (ADP), there is a macro set up the calls a stored procedure on a SQL Server 2005 database (which updates a table, but does not return any results). This macro is called when a user clicks on a button in a form. It works when logged in as the database owner and the ADP is opened, but when opened by a user with more r...