sql-server

Why cursor show error

work on SQL Server 2000. want to Automated Email Notifications using SQL Server Job Schedular.If i run the bellow cursor syntax in query analyzer than i get no error .But when i set this syntax on SqlServer agent->Jobs then it's create error. -- Script generated on 29-Oct-09 11:57 AM -- By: sa -- Server: (LOCAL) BEGIN TRANSACTION ...

How to filter the columns?

Using SQL Server 2005 I want to filter the column where column value not equal to numeric Table1 Status 010203 Absent 231415 Ramesh Suresh ..., I want to get only Names from the status column like Tried Query Select Status from table1 where status <> 'absent' and status <> numecivalue How to mentioned status <> numericvalue E...

Invoking CLR stored procedures

In short, where can I find C#/VB client side sample code that calls CLR stored procedure with some argumnet [like a sqlxml data] and receives a datareader or other form of result ? Also how do I periodically receive information from the running CLR stored proc sent through SQlContext.Pipe.Send() method ? ...

does oracle have a similar tool like sql server profiler

Possible Duplicate: Oracle: is there a tool to trace queries, like Profiler for sql server? hi all, i want to know whether there is a similar tool like sql server profiler in oracle. it is really useful. great thanks. ...

Does SQL Server handle unmanaged resources?

Does SQL Server handle unmanaged resources?please anser this ...

Some SQL Questions

Hello there, I have been using SQL for years, but have mostly been using the query designer within SQL Studio (etc.) to put together my queries. I've recently found some time to actually "learn" what everything is doing and have set myself the following fairly simple tasks. Before I begin, I'd like to ask the SOF community their thoug...

SQL Server 2005 Get Login name from User name

Hey, How can i specify a user name for a specific database and get the Login for that user in a query? Thanks. ...

Partition Or Separate Table

I am designing database for fleet management system. I will be getting n number of records every 3 seconds. Obviously, there will be millions of record in my table where I am going to store current Information of vehicle in the current_location table. Here performance is an BIG issue. To solve this, I received the following suggestions...

How to insert a blob into a database using sql server management studio

Hi, How can I easily insert a blob into a varbinary(MAX) field? for argument sake: assume the thing I want to insert is: c:\picture.png the table is mytable the column is mypictureblob and the place is recid=1 I've been googling for some time and I can't find a simple solution thanks! ...

Table variable poor performance on insert in SQL Server Stored Procedure

We are experiencing performance problems using a table variable in a Stored Procedure. Here is what actually happens : DECLARE @tblTemp TABLE(iId_company INT) INSERT INTO @tblTemp(iId_company) SELECT id FROM ..... The SELECT returns 138 results, but inserting in the TABLE variable takes 1min15 but when I use a temp table with the ...

Less repetition in where-clauses when querying many columns

Take a standard broad search query...: DECLARE @sq Varchar(50) = 'Desperate' SELECT * FROM [UnbelievablyHotWomenOrAtLeastAcceptable] u WHERE u.Address LIKE '%' + @sq + '%' OR u.City LIKE '%' + @sq + '%' OR u.firstname LIKE '%' + @sq + '%' OR u.Lastname LIKE '%' + @sq + '%' OR u.Email LIKE '%' + @sq + '%' OR u.Notes LIKE '%' + @sq + '...

List of DatabaseVersion values from RESTORE HEADERLISTONLY?

Is there a published list of expected values by SQL Server version that match to the DatabaseVersion column returned by a RESTORE HEADERLISTONLY command? For example, DatabaseVersion 611 = SQL 2005 SP_ ? Plenty of references for SQL Server build numbers to product versions (ex. SQL Server 2005 SP3 = 9.0.4035), my Google and Bing searche...

Why does bcp output null when the column contains an empty string and empty string when the column is null?

This struck me as really weird behaviour and I spent a while checking for bugs in my code before I found this "out copies from the database table or view to a file. If you specify an existing file, the file is overwritten. When extracting data, note that the bcp utility represents an empty string as a null and a null string as an empty ...

SQL Group By One Field and Order By Another Field

The Table: declare @Table table ( id int, ticketid int, sponsor int, dev int, qa int, savedate datetime ) insert into @Table values (1,100,22,0, 0, '2008-10-29 11:17:59.527') insert into @Table values (2,100,5,0, 0, '2008-10-29 11:00:37.030') insert into @Table values (3,101,22,0, 0, '2009-10-29 11:10:27.687') ins...

Adding a projection to an NHibernate criteria stops it from performing default entity selection

I'm writing an NHibernate criteria that selects data supporting paging. I'm using the COUNT(*) OVER() expression from SQL Server 2005(+) to get hold of the total number of available rows, as suggested by Ayende Rahien. I need that number to be able to calculate how many pages there are in total. The beauty of this solution is that I don'...

Not able to remove injected script from database rows

I've been handed a MS SQL 2000 database which has been injected with malware. The malware script is as follows: <script src=http://www.someAddress.ru/aScript.js&gt;&lt;/script&gt; Now I want to remove this piece of code from the table rows. As a test, I inputed < h1> Test < /h1> on a row, and successfully ran the following query: UP...

Creating tables with something similar to INFORMATION_SCHEMA.VIEW_DEFINITION in SQL Server

Is there a standard method to retrieve the 'CREATE TABLE..' definition of a table in SQL Server? I can ask INFORMATION_SCHEMA for definitions of views and functions/procedures, so I thought it would be natural to get the same for tables, but I didn't find anything. ...

DROP...CREATE vs ALTER

When it comes to creating stored procedures, views, functions, etc., is it better to do a DROP...CREATE or an ALTER on the object? I've seen numerous "standards" documents stating to do a DROP...CREATE, but I've seen numerous comments and arguments advocating for the ALTER method. The ALTER method preserves security, while I've heard...

How do I add a column to large sql server table

I have a SQL Server table in production that has millions of rows, and it turns out that I need to add a column to it. Or, to be more accurate, I need to add a field to the entity that the table represents. Syntactically this isn't a problem, and if the table didn't have so many rows and wasn't in production, this would be easy. Reall...

Can queries that read table variables generate parallel exection plans in SQL Server 2008?

First, from BOL: Queries that modify table variables do not generate parallel query execution plans. Performance can be affected when very large table variables, or table variables in complex queries, are modified. In these situations, consider using temporary tables instead. For more information, see CREATE TABLE (Transact-SQL). Que...