sql-server-2008

Sql server version error...655 version needed but you computer has 612 or earlier version ? error

Hi i have a error like " dbFileName cannot be opened because it is version 655. This server supports version 612 and earlier. " what should i do ? some friend of mine done a project but i guess he done it with sql 2008 and i have sql 2005 is that the reason why i got this error? can i fix it ? if i setup a newer version of sql does it ...

When is it better to write "ad hoc sql" vs stored procedures

Possible Duplicate: Inline SQL vs Stored Procedures I have 100% ad hoc sql through out my application. A buddy of mine recommended that I convert to stored procedures for the extra performance and security. This brought up a question in my mind, besides speed and security is there any other reason to stick with ad hoc sql quer...

SQL Server query replace for MySQL Instruction

Hi, I'm new to SQL Server, and used mysql for a while now... SELECT A.acol, IF(A.acol<0,"Neg","Pos") as Column2 From Table I want to do something like that on SQL Server, but there doesn't exist the IF instruction. How do I replace that if, in a SQL Server 2008 Query? ...

How can we check that table have index or not ?

Hi, How can we check that table have index or not ? if have how to find that index for a particular column for a table? Regards, kumar ...

Restful WCF Data Service to up- and download large files?

Hi, I'm thinking about to write a restful service which is able to upload and stream large video files (GB) (in future it might not only be videos and could also be large documents. I researched so far and what really makes sense to me could be to use off: WCF Data Services and Implement IDataServiceStreamProvider and on the back-end ...

Adding a new column to Table which contains live data

I have a large table consisting of over 60 millions records and I would like to add 2 new columns for data migration purposes. There are indexes on the table and some of them are large. So, by me adding the 2 new columns to the table, will I run the risk of slowing down the database whilst it attempts to add them and maybe time-out? O...

How to track number of changes occured in a column? T-SQL - SQL Server

For example, i have a column named EmployeeName. Every time a user changes/fix his name, i need to keep a count. If he changes his name twice, then count is 2. Also, i need to store the time of every change employee makes on EmployeeName e.g. if the name essentially is James and time created is 9:00 AM and then employee changes to John ...

Is it possible to connect to remote SQL Server database from Oracle 10g ?

I want to fetch data from remote SQL Server 2008 from Oracle 10g without installing anything on remote machine .. How can I achieve that ? ...

SQL Server insert with XML parameter - empty string not converting to null for numeric

I have a stored procedure that takes an XML parameter and inserts the "Entity" nodes as records into a table. This works fine unless one of the numeric fields has a value of empty string in the XML. Then it throws an "error converting data type nvarchar to numeric" error. Is there a way for me to tell SQL to convert empty string to nu...

Tsql can't update the column with count statement

declare @t1 Table ( a1 int ) insert into @t1 select top 10 AnimalID from Animal --select * from @t1 declare @t2 table ( dogs int null ) update @t2 set dogs = (Select COUNT(*) from @t1) ---------> The out put it gives me is just 0 ...

SQL Server: Deleting Rows with Foreign Key Constraints: Can Transactions override the constraints?

I have a few tables where Foreign Key constraints are added. These are used with code generation to set up specific joins in generated stored procedures. Is it possible to override these constraints by calling multiple deletes within a transaction, specifically "TransactionScope" in C# or is cascaded deleting absolutely required? ...

SQL Server JOIN with optional NULL values

Imagine that we have two tables as follows: Trades ( TradeRef INT NOT NULL, TradeStatus INT NOT NULL, Broker INT NOT NULL, Country VARCHAR(3) NOT NULL ) CTMBroker ( Broker INT NOT NULL, Country VARCHAR(3) NULL ) (These have been simplified for the purpose of this example). Now, if we wish to join these two tables on the...

Is there any performance difference between a SQL "IN" statement versus using "OR"?

Thought I would ask the knowledgeable StackOverflow community a question that was on my mind today and I can't seem to find an answer. Is there any performance difference or advantage between an "IN" or using "OR"? Ie. Is SELECT type FROM types WHERE typecat IN ('abc', 'def') better than SELECT type FROM types WHERE typecat = 'abc' ...

SQL How to correctly set a date variable value and use it?

Hi, I have the following query which uses a date variable, which is generated inside the stored procedure: DECLARE @sp_Date DATETIME SET @sp_Date = DateAdd(m, -6, GETDATE()) SELECT DISTINCT pat.PublicationID FROM PubAdvTransData AS pat INNER JOIN PubAdvertiser AS pa ON pat.AdvTransID = pa.AdvTransID WHERE (pat.LastAdDa...

Database table copying

I am trying to rectify a previous database creation with tables that contains data that needs to be saved. Instead of recreating a completely new database since some of the tables are still reusable, I need to split a table that exists into 2 new tables which I have done. Now I am trying to insert the data into the 2 new tables and becau...

How to manage GetDate() with Entity Framework

I have a column like this in 1 of my database tables DateCreated, datetime, default(GetDate()), not null I am trying to use the Entity Framework to do an insert on this table like this... PlaygroundEntities context = new PlaygroundEntities(); Person p = new Person { Status = PersonStatus.Alive, ...

Where are SSIS Packages Saved?

I right clicked on a Database in the object explorer of SQL Server 2008 Management Studio. I went to Tasks > Import Data, and imported some data from a flat text file, opting to save the package on the server. Now how the heck do I get to the package to edit or run it again? Where in SQL Server Management Studio do I go? I've expanded e...

Schema objects not visible in SQL Server Management Studio 2008

I'm experiencing a weird problem with a SQL login. When I connect to the server in Microsoft SQL Server Management Studio (2008) using this account, I cannot see any of the tables, stored procedures etc. that this account should have access to on a particular database. When I connect to the same server within Visual Studio (2008) with t...

SQL Server: How do I convert all varchar(max) columns to text type?

How do I convert all varchar(max) columns to text type? I know varchar(max) is recommended but I still want to use type text because CakePHP doesn't automagically convert varchar(max) to textarea (HTML form). How do I do it? Thanks in advance ...

How to remove empty lines in SSMS?

I have many .sql files with lots of empty lines e.g. WITH cteTotalSales (SalesPersonID, NetSales) AS ( SELECT SalesPersonID, ROUND(SUM(SubTotal), 2) FROM Sales.SalesOrderHeader WHERE SalesPersonID IS NOT NULL GROUP BY SalesPersonID ) SELECT sp.FirstName + ' ' + sp.LastName AS FullName, sp.City + ',...