sql-server-2008

sql server 2008 snapshot agent problem

Hi! I've just installed mssql 2008 sp1 x64 on windows 7 RTM, and have the problem with creating snapshots, whenever I try to launch the snapshot agent (i.e. to setup transactional replication publication), it throws the error that 'the file is missing'. I have looked into c:\program files\microsoft sql server\100\com and there are no exe...

Remove Change data capture manually

I'm having a serious problem with one of my production databases. The database was enabled for change data capture which was performing quite well. Last month we had a server meltdown where several disks were affected and data was lost. We then recoverd the database backups from tapes and restored them on the freshly installed database ...

Classic ASP - SQL Server 2008 Connection String using Windows Authentication

This should be painfully simple, but I cannot come up with a working connection string for a local copy of SQL Server 2008 using Windows Authentication. I've tried using the Data Link Properties tool to create a connection string and it has no problems connecting, but when I copy paste the generated string into my ADODB.Connection object...

LINQ2SQL - Cross join emitted when I want inner join

This emits inner joins, which is what I want and works: var q = from itm in esdc.items join itmImg in esdc.itemImages on itm.itemId equals itmImg.itemId join itmIdent in esdc.itemIdentities on itm.imgIdentityId equals itmIdent.itemIdentityId join startImgs in esdc.vStartPgImgs on itmImg.imgId equals startImgs.imgId s...

Unable to connect to SQL Server 2008 Express from Virtual PC machine

Hello everybody I have the following configuration: A host Windows Vista Home Premium SP2 with SQL Server 2008 Express SP1 and SQL Server Management Studio. A Virtual PC 2007 machine with Windows Vista Ultimate, Visual Studio 2008 Express and Visual Studio 2010 Beta 1. With SP1 on the host machine and before installing Vista SP2 and...

sqlcmd goto isn't quite working—ends script on error

I am using the sqlcmd tool with SQL Server to execute scripts. The scripts add/update records. I need sqlcmd to stop executing and give a non 0 return value if the script throws an error. I thought the following would work but it does not. DECLARE @intErrorCode INT BEGIN TRAN T1; SET IDENTITY_INSERT dbo.SomeTable ON INSERT INT...

How to do this Transform for millions of Rows

Input : Pairs of From->To Rows. From To 1 2 2 3 3 4 6 7 Output: For Each From Value, pairs of reachable To values. E.g. for 1 Source Reachable 1 2 1 3 1 4 Obviously, one can suck out the data to a Graph structure and run DFS scan. Is there a alternative way to do so, such that: Uses SQL/Fu...

malfunction of FTS usage

hi friends i created a FTS by this article i have a column with type of varbinary(max) that i filled it with MSWord file(.doc) and another column with type of word(filled by .doc). when i run this script , the output is empty SELECT name, content FROM tblWordFiles WHERE FREETEXT(content, '1'); or SELECT name, conte...

list of tables without indexes in sql 2008

How do I list tables without indexes in my SQL 2008 database? Edit I want the Schema name and the Table name. ...

What's your preferred method for generating datasets in SSRS?

I am trying to figure out what is the 'best' (read: "your preferred method") way to generate datasets for SQL Server Reporting Services Reports (either 2005/2008): In-report queries Stored procedures Views But more than just choosing one of the above, why would you use that particular method? Also, please include your perspective (De...

Sql Server 2008 - BEFORE triggers?

Hi all... I've long been waiting for BEFORE triggers. But we have some systems which are written in ORACLE. When a potential new client asked why, our president told them that it was because there are no BEFORE triggers in Sql Server (among other things). To this, the client responded, "Yes, in 2008 you CAN write BEFORE triggers." No...

How about the performance between PATINDEX and CHARINDEX?

At all times I use CHARINDEX in stored procedure to check NVARCHAR(MAX) type of variable, but today I find that the CHARINDEX has an 8,000 byte limit! I find this article SQL CHARINDEX() Has Data Size Limitations. So I replace CHARINDEX with PATINDEX, but I do not know the performance between PATINDEX and CHARINDEX. ...

SQL 2008 report manager not accessible

I have a SQL 2008 developer edition with SSRS and the report manager is only available from the local machine. If I try to access it from any other machine I get challenged for my domain u/name and pwd 3 times and then the screen stays blank. I have made changes to some config files (originals copied out) in order to get a 3rd party app...

Complex WHERE expression using CASE-THEN in SQL 2008

I have a query: SELECT ID FROM requests WHERE date <operator> <expression> I need to change <expression> relying on my stored procedure's parameter. If flag is set: WHERE date BETWEEN GETDATE() - 7 AND GETDATE() If is not: WHERE date = date I tried to use CASE-THEN but it forces using concrete operator but I have to have few: SELE...

Rename a stored procedure in SQL Server

I'm attempting to rename a stored procedure in SQL Server 2008 with sp_rename system sproc. The third parameter is giving me difficult though and I keep receiving the following error: Msg 15249, Level 11, State 1, Procedure sp_rename, Line 75 Error: Explicit @objtype 'P' is unrecognized. As the message indicates I'm passing in a P fo...

How can I detect which version of SQL (eg SQL 2008 or SQL Azure)

I need to detect which version of SQL I am dealing with to perorm various tasks, I need specifically detect if I am on SQL 2008 or SQL Azure. How can I do this with detection code written in SQL? ...

SQLXML in SQL server

I'm having an small issue with SQLXML in SQL Server 2008. Here's my testing SQL query DECLARE @XMLTable TABLE(GameHistory XML) INSERT INTO @XMLTable VALUES( '<game xmlns="http://my.name.space"&gt; <move> <player>white</player> <piece>pawn</piece> <start>A2</start> <end>A3</end> </move> <move...

Install Sql Server 2008 first or Visual Studio 2008?

I never really know what order is the best installation or if it even matters, but should you install sql server (2008 in this case) first and then Visual Studio or vice versa or does it not matter? ...

Is SQL 2008 GETDATE() expensive as DateTime.Now is?

I have heard that DateTime.Now is very expensive call (from here) Is GETDATE() in SQL 2005/2008 expensive? Have I to cache it into a variable if my stored procedure uses it a number of times? ...

Logging SQL Errors

SQL Server 2008 has a new try/catch structure. If I encounter an error in a sequence of nested stored procedures, I like to log the call stack in an error table. The problem is that if I have started a transaction (which will be true for operations that update the db), an records written to the error table will be removed when the code...