sql-server

show data from sql server in blackberry using .Net

Hi all, i want to ask about development in blackberry. I have background in .Net winform. If i want to develop an application to show data from Ms.SQL server 2008 database in blackberry. what should i learn and what should i do ? thank you for your advice. ...

Optimizing T-SQL where an array would be nice

Alright, first you'll need to grab a barf bag. I've been tasked with optimizing several old stored procedures in our database. This SP does the following: 1) cursor loops through a series of "buildings" 2) cursor loops through a week, Sunday-Saturday 3) has a huge set of IF blocks that are responsible for counting how many Objects of ...

Why is variable declared inside IF statement created even when condition evaluates to false?

Since @A is never declared, sql server should throw an error, but it doesn’t. Why is that? DECLARE @i int = 1; IF @i > 10 BEGIN DECLARE @A int = 100; END PRINT @A; // doesn't return any result thanx ...

Cross-database transactions from one SP

I need to update multiple databases with a few simple SQL statement. The databases are configurared in SQL using 'Linked Servers', and the SQL versions are mixed (SQL 2008, SQL 2005, and SQL 2000). I intend to write a stored procedure in one of the databases, but I would like to do so using a transaction to make sure that each database...

View changes nvarchars to varchars in SQL Server 2008

I have a view in a SQL Server 2008 db that simply exposes about 20 fields of one table to be consumed via ODBC to a client. When I tried to replicate this view in another database, the client could not consume the data source. Then I noticed some weirdness. The columns in the view are shown, in SQL Server Management Studio, to be varc...

SQL injection attempt on my server

I know a little about SQL injections and URL decode, but can someone who's more of an expert than me on this matter take a look at the following string and tell me what exactly it's trying to do? Some kid from Beijing a couple weeks ago tried a number of injections like the one below. %27%20and%20char(124)%2Buser%2Bchar(124)=0%20and...

.Net SQL Server Connection String - hide password from other developers

We're migrating one of our sites to ASP.Net. We do not want to use integrated security, which uses the windows account to connect to sql server (not going to get into why, its just out of the question). We created a username and password to connect to SQL Server, and would like to use that username and password, however, we also do not w...

Help with Linked Server Error

In SSMS 2008, I am trying to execute a stored procedure in a database on another server. The call looks something like the following: EXEC [RemoteServer].Database.Schema.StoredProcedureName @param1, @param2 The linked server is set up correctly, and has both RPC and RPC OUT set to true. Security on the linked server is set to Be...

SQL using sp_HelpText to view a stored procedure on a linked server

Anyone have an idea about how to use sp_helptext to view a stored procedure on a linked server? basically something like this. I don't have the credentials to that linked server to look at it. EXEC sp_HelpText '[ServerName].[DatabaseName].dbo.storedProcName' thanks ahead. ...

Turn Function or Stored Procedure Result into "live" Result for LINQ

Is it possible to turn result sets obtained in LINQ through a stored procedure or function call into a "live" set of objects of which I can retrieve Foreign Key related objects? If, for example, my stored procedure returns a set of rows (= LINQ objects) of type "Contact", then I can't seem to obtain Contact.BillingAddress (which is rela...

Is it possible to get the client process ID of an application that runs on SQL server?

Hi all, For my VFP application, i have a program to check currently who is accessing the server (by using sp_who2), also another progam to check who is currently locking which table. But i wish to know which options my users is accessing at the moment. Am thinking if i can write a SP to get the current connected process ID for a spec...

Export a data table in CSV format sql server 2008

I need to create a stored procedure which queries a table and creates a CSV file for that data in a specified directory location. how do i do it? ...

How to constrain a table linking two tables in many-to-many relationship

Say I have the following tables and columns: comp: id, model dvd: id, model comp2dvd: id, id_comp, id_dvd A computer can have multiple dvd drives, even of the same model, and a dvd drive can appear in multiple computers. How do I make it so that comp2dvd table can have only existing comp and dvd id...

Can Microsoft store three-valued fields in a single bit?

I'm completely ignorant of SQL/databases, but I was chatting with a friend who does a lot of database work about how some databases use a "boolean" field that can take a value of NULL in addition to true and false. Regarding this, he made a comment along these lines: "To Microsoft's credit, they have never referred to that kind of field...

SQL Server T-SQL statement to replace/delete sub-strings

Hi, I have a table with 6 columns containing HTML content with some markups in it and now when moving to a new designed site most of this HTML code has to be deleted. More or less all tags except <B> and </B>. Is there a nice way of doing this, identify all tags end delete them within the data? I'm sure there are no < > symbols in the ...

Run sql script from console and not from query analyzer in SQL server

I have written an sql script for updating a database that runs in SQL server 2005. I want to make those changes to the production DB server but I dont want to run the query from the query analyzer. Is there a way to run the sql script from a console? ...

Text replace with regex in SQL Server

Currently I have a SQL server column of type nvarchar(max) which has text that starts with <span class="escape_<<digits>>"></span> The only thing that varies in the pattern is the <<digits>> in the class name. The common part is <span class="myclass_ and the closing </span> Some sample values are <span class="myclass_12">...

Is there a way in SQL Server to uniquely identify a database?

Is there any way to uniquely identify a database? If we were to copy a database to another machine, this instance is assumed to be different. I checked on master tables, but could not identify any information that can identify this. ...

Finding efficient overlapped entries in a SQL table

What is the most efficient way to find all entries which do overlap with others in the same table? Every entry has a start and end date. For example I have the following database setup: CREATE TABLE DEMO ( DEMO_ID int IDENTITY , START date NOT NULL , END date NOT NULL ); INSERT INTO DEMO (DEMO_ID, START, END) VALUES (1...

Strange Values in SYS.DM_TRAN_LOCKS table RESOURCE_ASSOCIATED_ENTITY_ID column

I’ve been trying to understand some strange values in the RESOURCE_ASSOCIATED_ENTITY_ID column of SYS.DM_TRAN_LOCKS when RESOURCE_TYPE is “OBJECT”. Although these should be object Ids, I cannot determine what object they actually refer to. I’ve tried everything I can think of, including querying all system tables with columns of type IN...