sql-server

SQL Server Management Studio 2008 Install

I installed SQL EXPRESS 2008 Advanced then I downloaded 64 bits Management Studio. It says install service pack 1 for SQL. I downloaded service pack 1, it says nothing to update :( So how do I install management studio? ...

Bookmark Lookups - How efficient is the lookup using a row pointer?

I'll use this simple query as an example: Select MyColumn From MyTable Where PrimaryKeyColumn = 10. Let's assume the table has no clustered index and there is a primary key on PrimaryKeyColumn. If I understand correctly, the query plan will include an index seek on the primary key and a bookmark lookup on the table, using some sort of...

Sql Server 2000 openrowset issue.

I’m attempting to query and Excel spread sheet on a network share, using the openrowset function with no success. I get the following error: SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;DATABASE=\\server\Xdrive:\Spreadsheet.xls', 'Select * from [Sheet1$]') Server: Msg 7399, Level 16, State 1, Line 1 O...

Pass timestamp between Powerbuilder datawindow and SQLServer insert/update stored procedure

Hi, can anyone help me out. By implementing countermeasures in solving the concurrency problem I got troubled with passing timestamps (rowversion) between Powerbuilder 7 datawindow and SQLServer 2008 (both ways) using insert and update stored procedures. The connection is serviced by ODBC, not native. Most of my attempts result in cas...

Database sorting SQL Server

Hi folks! I made a windows app and I need to add a "sort" by selected column. The grid has 4 columns and lot of records (paged of course). The question is: Should I consider to add an index for every column that need sorting in the grid? thanks in advances. Regards ...

SQL to detect similar records in the same database table

I have a requirement to loop through records in a database table and group items that have similar content. I want to match on a single column in the database and if there are similar records I want to extract the ID of each row and save it to another table e.g. if I had 10 similar rows they would be linked to one "header" record in anot...

i get an error when creating a variable and specifing the collation in sql server 2005

when i tried this: DECLARE @var nvarchar(500) collate Arabic_BIN i got that: Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'collate'. that is the full code, it works, i do not know how but the person who give it to me have used it successfully CREATE FUNCTION fn_RemoveTashkeel (@InputString nvarchar(2300) ) ...

What's the best way to create custom sorting (for data like "07/2010") in EF 4.0?

I have some table that contains annual sequence data in column like "1/2010", "2/2010" or "13/2010". I want to order data from this table by this column. So I should create order value for sorting like that the following SQL expression. -- This code should work if amount of data is less than 1000 record per year. CAST(SUBSTRING(ReceiveI...

How To Return All Instances Within ## Mile Radius of a List of Zipcodes

SQL Server 2008 has added some cool new Spacial types and given SQL Developers a lot more powerful ways of manipulating spacial data but it still eludes me how to efficently return, for example, only the locations that are within ## mile radius of a long list of zips (20 to maybe 15 thousand distinct zipcodes). Is there a simple way to ...

Insert into from temp table - creating too many rows

I am bulk importing CSV file into a temporary table and then inserting the rows into the target table if they do not already exists. When I start the process, my table has the following values VECH01 AAA 111 VECH01 BBB 222 VECH01 CCC 333 VECH02 AAA 111 VECH02 BBB 222 VECH02 CCC 333 When I import a CSV file with these values: VECH01...

Dynamic TSQL in a secure context

I have a database where the primary user logging into the database has no permissions to any of the tables directly. THe user needs to execute stored procedures which have been explicitly granted to it. This covers any straightforward CRUD operation that is needed. But now, I have a need to execute SQL Dynamically but I want to maintain ...

Error trying to use datasource in SQL Server Analysis Services

Does anyone know how to resolve the issue when presented with the following error message when trying to select a datasource for a report in SQL Server Analysis Services? Non-Windows user credentials were supplied for a non-http connection to Analysis Services. The Microsoft SQL Server Analysis Services data extension requires Windows I...

Trouble turning a Simple MsSQL select into a monitor

I have a SQL Statement that works as I want. select COUNT(*), MIN(emailed_to)from email.email_archive group by emailed_to order by COUNT(*) desc The output looks like this. 13 [email protected]; 8 [email protected]; 4 [email protected]; ... ... ... 1 deadlockFF17uyt...

Why is SQLServerCE query performing a table scan and is it an issue?

I'm trying to optimise a query for a SQLServerCE database running on a Windows Mobile device. The query is used to identify rows to delete in one table based on no longer being referenced from a different table. The original query used a DISTINCT to identify matching rows: SELECT TestGroupId, TestNameId, ServiceTypeId FROM ServiceTypeIn...

"SQLCMD -L" fails - why?

I am having 2 instances of SQL Server 2008R2 and instance of SQL Server Express 2008. SQLCMD, etc., works [1]. But "SQLCMD -L" and "OSQL -L" fail [2]. Why? What am I missing in SQLCMD use? How to use SQLCMD to get servers? [1] Test results of SQLCMD >sqlcmd 1> use AdventureWorks2008R2; 2> SELECT TOP(2) BusinessEntityID, FirstNa...

Stored procedure that deletes records by looping through Id's

So I am really confused on how to write this proc. Here is what needs to be done. I have 3 tables laid out as follows: tblObject {ObjectId, MasterId} tblAnotherObject {ObjectId} tblFurtherObject {ObjectId} I need a proc that can delete the rows in 'tblAnotherObject' and 'tblFurtherObject' that contain an 'ObjectId' that does NOT hav...

The tablix 'Tablix1' is invalid. The value for the DataSetName Property is missing - Help

For some weird reason i can not run my report, when i try to preview i get this error: (PLEASE RIGHT CLICK THE IMAGE AND CHOOSE VIEW IMAGE TO SEE IT LARGE) Here is how my tablix property looks like: Any idea what to do? The current .rdl was copied from another one. I changed the newly copied .rdl values to match my needs. I always...

problem in update query!!

I had written a query like this string strUpdateQuery = "UPDATE M_QA SET ANSWER = '" + txtEditorAnswer.Text.Trim().Replace("'", "''") + "', UPDATED_ON = getDate(), UPDATED_BY = '" + this.Session["UserId"].ToString() + "' WHERE PK_ID = " + _currentQuestionId + ...

CAML queries against a database hosted on a RDBMS other than SQL Server?

Hi there, We have a SharePoint 2007 site. It is supported by two back-end databases - one hosted on SQL Server, another on an open-source RDBMS. We issue CAML queries to retrieve data from SQL Server, and ADO.NET queries to retrieve data from the other server. Our architect says we would be better off if we used the same approach (namel...

Is there any Query to find the SP which contains errors?

I am working in Sql Server 2008 and there is a change of table in my database. So I need to know which all the queries I am using that table or I need to know which all queries will throw errors.I has changed some SP to work fine.But there is a lot of queries which may cause errors.So If there is possible to find which all queries will r...