sql-server-2008

Using a table variable inside of a exists statement

I am trying to update a column inside of a table variable based on a condition, the condition being that the ID of the table variable does not exist in a different table: DECLARE @BugRep TABLE(BugCode VARCHAR(50),DevFirstName VARCHAR(50), DevLastName VARCHAR(50), BugDate VARCHAR(20), IsValid VARCHAR(1)) UPDATE @BugRep SET IsValid =...

any limit of SQL Server connection count?

Hello everyone, I am using SQL Server 2008 Enterprise + C# + ADO.Net + .Net 3.5. I am using sp_who2 or sys.dm_exec_connections to find active connections numbers (let me know if my method to find active connection numbers are wrong). For some heavy database consumer application, I can find even active connection count > 1000. I am wond...

connection leak issue in SQL Server

Hello everyone, I am using SQL Server 2008 Enterprise + C# + ADO.Net + .Net 3.5. I am using connection pool at ADO.Net client side (the default behavior of ADO.Net). I am using sp_who2 or sys.dm_exec_connections to find active connections numbers (let me know if my method to find active connection numbers are wrong). If each time after...

How to Script Automatically, the securables assigned to a SQL account

I want to generate script to assign an user account to some securables, e.g. Table:Select. How to do this? ...

The best online resources for full-text searching in Microsoft SQL?

So I've learned the difference between FREETEXT, FREETEXTTABLE, CONTAINS, and CONTAINSTABLE. And I've created a pretty cool search engine that combines a full-text enabled search with a tagging system (with a little help from you guys). But where have you gone to really learn about and master full-text searching and get the most out of...

Can someone please help me with this SQL 08 query? Error when running is....

I am having trouble with the following query which returns the following error: 'Article' is not a recognized option. Incorrect syntax near the keyword 'ON' Is there something obvious wrong that you can point out?? ( @PageIndex int, @PageSize int ) WITH Article AS ( SELECT tbrm_Article.ArticleID, tbrm_Article.CountryID, tbrm_Arti...

What are the strategies for a really fast single table database?

Hello there! I have a database in SQL Server 2008 that supports various applications. I am now starting the development of a new application and, from that database, I require data that fits in one table (though there is some replication). The data I way may be extracted to a view (a few inner joins) with 6 columns. I'm developing a we...

So close to getting a big stored proc to work, just this last problem with CROSS APPLY. Can you help?

The below cross apply sql statement is the only part of a stored proc i cannot get to work. The error says that there is incorrect syntax near the keyword 'ON' Can anyone see the problem? The select statement works fine if that helps at all. CROSS APPLY ( SELECT tbrm_Votes.ArticleID, AVG(tbrm_Votes.Truth), AVG(tbrm_Votes.Relevanc...

SQL Server 2008 - find table with most rows

Is there a way in SQL Server 2008 to find the table with the most rows in the database? ...

Sql Reporting Services Parameter Question

I'm new with SQL Reporting Services 2008 and cannot find out how to do something that should be simple. What I have is a single select parameter that is populated with a list of salesman from a query. This works great. And I have the dataset query responding to this parameter working well. So my reports for a single salesman are work...

How can I compare two variables/columns of type NTEXT

I know I can convert the variables to nvarchar(max) first and then compare with the = or <> operators. But is this the right way? ...

"The SQL Server 2008 was not found or was not accessible"?

The SQL Server was not found or was not accessible I got this error while setting up a system that requires a remote computer to access SQL 2008 stored on another computer in the same domain: The server was not found r was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connect...

SSRS mail error: "The filename, directory name, or volume label syntax is incorrect"

I am trying to configure SQL Server Reporting Services to send email. The environment is: Windows Server 2008 Enterprise SQL Server 2008 Enterprise SSRS running in Native mode SMTP server via IIS7, configured as a restricted relay After a user configures a subscription for mail, when it's triggered the status changes to the following...

sql server 4 byte unsigned int

Does anyone know of any work around by which i can save unsigned integers (0 to 4294967295) simply using 4 bytes instead of using 8 bytes and bigint? I know we can create user defined datatypes and create a constraint on them to not allow negative values but that still does not allow me to enter values over 2147483647. I only want to u...

convert varchar into datetime in sql server

How do i convert a string of format -> mmddyyyy into datetime in sql server 2008? My target column in 'DateTime' I have tried with Convert and most of the Date style values - I get a 'The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.' error message ...

Invoke-Sqlcmd cmdlet throws exception when using -Variable parameter

When I try to use the Invoke-Sqlcmd cmdlet from SQL Server 2008 to execute a query that contains scripting variables, ex. $(MyVar), I receive the following exception: Invoke-Sqlcmd : Object reference not set to an instance of an object. Here's the code I'm trying to run (which is copy/paste from the Books Online example with only t...

SQL 2008 stored proc returns nothing if CROSS APPLY is nothing. How can I fix?

The below stored proc returns data from a number of related tables and also does a cross apply on the votes table. This cross apply returns an average of all truthfulness values in the truthid column associated with a particular articleid and the same for the relevanceid column. This works great except for when there are no votes yet cas...

How do I return a value to a sqldatareader if value is null?

I am currently using a sql data reader (in vb.net) to extract an article object via a stored proc from a SQL Server 2008 database. Part of this object includes the two properties shown below: theArticle.Truthfulness = ((myReader.GetInt32(myReader.GetOrdinal("Truthfulness")))) theArticle.Relevance = ((myReader.GetInt32(myReader.GetOrdina...

Using LEFT on a TEXT-field in SQL Server

In a table, I have a text-field. I need to be able to select only the first 200 chars of the field - but LEFT does not work with TEXT-fields. What to do? ...

How can I have my C# application use a single FILE database?

Right now I have my program running on my SQLExpress database. But what I'd really like is for my program to run on any machine as long as A DATABASE FILE is in the same folder. How can I accomplish this? Firs things's first: How would my connection string be if I were connecting to a FILE DATABASE? Second: How do I create a single fil...