sql-server

Return an Oracle Ref Cursor to a SqlServer T-SQL caller

Is it possible to return an Oracle Ref Cursor to a caller that is in SqlServer T-SQL? When dealing with a normal .Net program there is this Knowledge Base article: http://support.microsoft.com/kb/322160 But is this same type of thing possible from T-SQL? ...

SQL Server Automatic Rounding ?

Hi fellows, I am very confused by the following results: PRINT 3.1415926535897931 /180 Console result = 0.01745329251994329500 DECLARE @whatTheHell float(53) SET @whatTheHell = 3.1415926535897931/180 PRINT @whatTheHell Console result = 0.0174533 I don't understand because referring to this: http://msdn.microsoft.com/en-us/libra...

Subsonic 3/ASP.net MVC issue trying to override class column properties

I am using Subsonic 3 (T4 template) to generate the models for my mvc app. However the default template does not allow for nullable columns, so when I go to save the record it errors out if a nullable datetime column is blank. (See this post...) Question: What is the best practice to handle this? Option 1: Change the template to ch...

Using Access to change SQL tables. Table randomly becomes read-only.

I have a database that the client needs to update. They like to you access. Some tables randomly become read-only for them. Any ideas why? They are using Access 2007 and MS SQL 2005. SQL Table: CREATE TABLE [dbo].[Users]( [SyncGroup] [varchar](20) NULL, [UserID] [varchar](20) NOT NULL, [Password] [varchar](20) NOT NULL, ...

SQL Server replication without deletes?

Is there a way to replicate a sql server database but not push out deletes to the subscribers? ...

grabbing first result set from a stored proc called from another stored proc

I have a SQL Server 2005 stored proc which returns two result sets which are different in schema. Another stored proc executes it as an Insert-Exec. However I need to insert the first result set, not the last one. What's a way to do this? I can create a new stored proc which is a copy of the first one which returns just the result set ...

Difference between a inline function and a view

I am a newbie in using functions and it appears to me that an inline function is very similar to a view. Am I correct? Also, can I have UPDATE statements within a function? ...

Using a variable for table name in 'From' clause in SQL Server 2008

I have a UDF that queries data out of a table. The table, however, needs to be definable as a parameter. For example I can't have: Select * From [dbo].[TableA] I need something like: Select * From [dbo].[@TableName] The above line doesn't work, and also the UDF prohibits me from setting the query as a string and calling exec(). I can...

"Invalid character value for cast specification" for linked 2008 SQL server in 2005 instance

I am attempting to create a linked server from a 2005 to 2008 Microsoft SQL Server. I do this regularly for 2005 instances, but this is the first step of my long journey into SQL 2008. I am able to create the linked server as any other linked server, I receive no errors, however any time I try to use the linked server for anything (a sim...

Can Reporting Sevices be used to format XML returned in an XML data type column?

Using SQL Server 2005 and Reporting Services, I have a stored proc that returns several columns, one of which is of the XML data type. Can I manipulate/format/style that XML column in my Reporting Services report? If so, how? ...

T-SQL equivalent of Excel "MAX" function to return larger of two numbers

In Excel, there's a function called "MAX" that accepts numbers and returns the largest one in the set. Is there a function in T-SQL that duplicates this functionality? I haven't been able to find one, and I've written a UDF that does it for me, but I thought it was worth asking. Here is the function I've been using: CREATE FUNCTION dbo...

How to install Visual Studio 2008 and MS SQL Server 2008 in Ubuntu ?

Hi guys, I would like to install Visual Studio 2008 and MS SQL Server 2008 on Ubuntu OS which I have in my PC, however, I don't know how. May I have some tips please? Thanks. ...

Advice for minimizing locking on an append only table in MS SQL Server?

I'm writing some logging/auditing code that will be running in production (not just when errors are thrown or while developing). After reading Coding Horror's experiences with dead-locking and logging, I decided I should seek advice. (Jeff's solution of "not logging" won't work for me, this is legally mandated security auditing) Is the...

Calculating variances on dates in T-SQL

Guys, I am trying to write a stored procedure in T-SQL (SQL Server) that will select records based on a date field, keeping a variance of minutes in mind. Something like this: CREATE PROCEDURE spGetCustomers(@DateRange DATETIME, @Variance int) AS -- The next line is where I need help -- I'm trying to subtract X amount of minutes from th...

Finding bigram in a location index

I have a table which indexes the locations of words in a bunch of documents. I want to identify the most common bigrams in the set. How would you do this in MSSQL 2008? the table has the following structure: LocationID -> DocID -> WordID -> Location I have thought about trying to do some kind of complicated join... and i'm just doing...

Why does this transport-level error occur?

After a breakdown on my virtual webhost, they finally restored the container, but now I randomly get the error when I try to execute queries. I can do a Select top 20000 from Orders But Select * from Orders (about 100k rows total) Receives the error in my management studio: A transport-level error has occurred when rece...

Weird trigger problem when I do an INSERT into a table

Hi folks, I've got a trigger attached to a table. ALTER TRIGGER [dbo].[UpdateUniqueSubjectAfterInsertUpdate] ON [dbo].[Contents] AFTER INSERT,UPDATE AS BEGIN -- Grab the Id of the row just inserted/updated DECLARE @Id INT SELECT @Id = Id FROM INSERTED END Every time a new entry is inserted or modified, I wish to update a si...

Need help in SQL Rollback transaction

Hi all, I have updated my database with this query: UPDATE suppliers SET contactname = 'Dirk Lucky' So all the rows in the suppliers table have the contact name: "Dirk Lucky." How can I rollback this transaction? I want to restore my the contactname column in the suppliers table. Thanks, Programmer ...

Table with multiple languages

Hi, I want to store multiple translations of an text in a MSSQL database. for example one table product with the columns ProductId ProductPrice ProductNameId primairy key = ProductId and a table with the productnames Id Language Name primairy key = Id and Language How can i create an foreign key to link the Product.ProductName...

Migrating from MS SQL to MySQL: SQLOLEDB? Migration kit login error?

I've been put in charge of migrating a customer's website of MS SQL/ASP to PHP/MYSQL. I have zero experience with MS SQL. I'm trying to figure out the best way to get the current data migrated to MySQL so I can begin PHP development. Some details: I downloaded SQL Server Mangement Studio Express. I found the following string in...