sql-server-2005

Using table just after creating it: object does not exist

I have a script in T-SQL that goes like this: create table TableName (...) SET IDENTITY INSERT TableName ON And on second line I get error: Cannot find the object "TableName" because it does not exist or you do not have permissions. I execute it from Management Studio 2005. When I put "GO" between these two lines, it's working. But ...

SQL Server PWDEncrypt value comparison

I think what I am about to ask is impossible, however, figured it was worth a shot here. We have an application that makes use of SQL Servers PWDEncrypt and PWDCompare functions. Part of the system creates duplicates of users (same logon and password). Due to a bug in the system, instead of copying the binary stored PWDEncrypt of a pas...

Visual Studio 2008 Database Edition

Managing server logins and database users between developers workstations and other deployment environments using Visual Studio Team System Database Edition Hello people, Looking at upgarding from 'Visual Studio Team System 2008 Database Edition' to Visual Studio Team System 2008 Database Edition GDR R2. Parametrisation in vstsdb is ...

How to create a UDF that takes a query string and returns the query's resultset

I want to create a stored procedure that takes a simple SELECT statement and return the resultset as a CSV string. So the basic idea is get the sql statement from user input, run it using EXEC(@stmt) and convert the resultset to text using cursors. However, as SQLServer doesn't allow: select * from storedprocedure(@sqlStmt) UDF with E...

Is it possible to add languages/locales to SQL Server 2005?

The contents of sys.syslanguages lists several languages/locales, however is it possible to add languages? For example, I'd like to add Australian English and Canadian French. Any help is appreciated! ...

How to save all version of a modified file with minimum cost on a database

I recently got database for my website and was suprised to see how expensive it was for the amount of space they gave me (only 500 mb for sql2005). The database is used to store data such as posts or articles submitted by members. the problem: I would like to be able to save not only the final version of a user post, but also all possi...

How do I get SQL Server 2005 data stored as windows-1252 as UTF-8?

I have a client database with English and French data in windows-1252 encoding. I need to fetch this data as part of an AJAX call and send it in UTF-8 format. Is there a way I can pass the data through a stored proc to perform this conversion? My web app cannot be altered to perform this conversion itself. ...

SQL Server 2005 Replication

Environment: SQL Server 2005 SP2 (9.0.3077) Transactional Publications (Production and Beta) I have a situation where I have two different Replication Publications setup that use some of the same Articles. Each of these Publications feeds a subscriber on a different machine. One of these shared Articles is a table. At a regular time ...

SQL Server PIVOT help.

Source table: Create Table ExamAnswers { StudentID varchar(12), QuestionID int, Answer char(1) } and this will be filled with Bob 1 a Bob 2 c ... Bob 100 b Chris 1 c Chris 2 d ... Chris 100 null etc, for about 500 students. Chris did not finish the exam, but the 100th question is stored as null, so it is guaranteed that e...

Why won't an OLE DB data source update in SSIS?

I am calling a stored procedure from an OLE DB data source in SSIS. Why doesn't SSIS see changes I have made to the stored procedure? It seems like metadata about the stored procedure is cached somewhere. Is it cached? If so how do I force SSIS to see the changes I made to the stored procedure? ...

GIS find Points (long lats) that are contained by a polygon expressed as a collection of long lats

I'm trying to find all data items that have long/lats that are contained by a polygon made up of an array of long lats could be many points. I know you can do this kind of stuff with the new geospacial datatypes in SQL 2008 but i'm using SQL 2005 and C#. Would this be best done on at the DB end or in C#. Thanks. ...

MS SQL Server 2005 - case insensitive password problem

I am checking for username and password for login in a procedure in MS SQL SERVER 2005. Since SQL Server 2005 is case insensitive even if user gives a lowercase password instead of a upper case one, the system allows to login. What should I do?? Is there any command in Sql Server 2005 which can check the same?? ...

Getting distinct rows from a left outer join

I am building an application which dynamically generates sql to search for rows of a particular Table (this is the main domain class, like an Employee). There are three tables Table1, Table2 and Table1Table2Map. Table1 has a many to many relationship with Table2, and is mapped through Table1Table2Map table. But since Table1 is my main t...

sql server 2005: Value truncation

My table contains a field password whose size is Varchar(70). But when I enter the hash value of the password which is of size 40 the last few characters are getting truncated. I'm using SQL SERVER 2005. Why is it so?? ...

shortcuts for SQL 2005 Query

what are the different short cuts for performing usual tasks in SQL 2005. eg, ctrl+T to show the result in text format, ctrl+d in data format. ...

How to get first character of a string in SQL?

I have a SQL column with length of 6. Now want to take only first char of that column. Is the any string function in SQL to do this? ...

Query similar to TOP 10 to select inbetween records?

I have 100 records in which i can select top 10 using the "TOP 10" in the query. Similarly is there anything to get the 20th to 30th record? ...

Performance problem when updating a view (using an instead of trigger) via a cursor in Sql Server 2005

Dear all, I have a view V in database D1 on which an update trigger U is defined that updates three tables T1, T2 and T3 in database D2. Those three tables contain 0.75, 6.0 & 4.5 million records. The Sql Server version is 9.0.3042, Developer Edition. When I perform the following update statement on the above view it is ready within on...

How to send a mail such that when particular job executed in SqlServer

I am creating a job such that executes the following SQL statement. select * from emp where sal > 5000 It is scheduled to execute on 3 PM every day. Now my question is: How to configure mail or alert such that when the job executes I have to receive a mail or alert indiactes query executed suceesully ...

How to denormalize a heavily normalized database system?

I'm looking to introduce some database denormalization to a heavily normalized system. I have a large set of databases that have evolved over ten years and are under increasing amounts of load so I'm looking to improve PERFORMANCE and possibly reduce the complexity of some queries. It is not uncommon to do 10 joins to accomplish any ...