sql-server-2005

Problem filtering in decimal datatype in Sql server

I want to fetch all the records that have null in openingbalance field of my voucher table in sql server 2005 database. That field is of type decimal(18,0). My query is Select HeadCode,HeadName from VoucherHead where OpeniningBalanace = null what am i doing wrong? ...

T-SQL CTE Error: Types don't match between the anchor and the recursive part

I get the following error when I try to execute a particular recursive CTE: Msg 240, Level 16, State 1, Line 8 Types don't match between the anchor and the recursive part in column "data_list" of recursive query "CTE". This is nonsense. Each field is explicitly cast to VARCHAR(MAX). Please help me. I've read many answers to this prob...

Find and replace all links in database.

I want to find and replace in all db fields which contains a link in my database?how is that possible? I have more tables but i don't know which tables :),i need to search programmatically. I need to a method,example,GetContainsaLink(dbname) it should returns me tables and which field contains a link, I have already a dictionary map o...

for loop in Sql procedure

i want to implement for loop to fetch the data from select statement. ...

VS 2010/SQLServer 2005 debugging hangs.

When attempt to debug a SQL CLR Function the debugger hangs. Using VS2010 and SQL 2005. ...

query for delete duplicate records from a table without using temp table?

I want to remove duplicate records from a table without using temp table how is it possible? ...

SQL 2005 database roles and security

I Hope someone can clarify and help. I've moved to creating/using schemas in Sql Server 2005, where I've also created database roles and assigned schemas to the roles. The problem I have is one of the db roles I have should have full access - say SuperSysRole. However, when I assign a login to that role, it cannot execute specific comma...

How to get create scripts of sql server CE 2005 Tables

I am working on Sql server CE 2005. I have created a Database in Sql server CE 2005 now I want to get the scripts so that can use that further??? Is there any way to get create scripts from SQL server CE 2005 dataBase.. ...

Is it possible to load different size and weight images from one cloumn image Data Type ?

Hi , I'm going to design a database for an image gallery in ASP.NET Web App . Because of some reasons I've decided to store the image in Data Base , Not the address . In the application i need two or more different size and weight image for each image that the admin insert .For instance , One of them is small and lightweight thumbna...

SQL query to join values from multiple records

I've got a table Employees with employees (say the important fields are ID int, Name varchar(50)) and a table Areas with sales areas (ID int, EmployeeID int, USState char(2)). The sample values are: Employees ID Name 1 Shoeman 2 Smith 3 Johnson Areas ID EmployeeID USState 1 1 NY 2 1 ...

Can't connect to database, error 80040e21. Impossible to debug.

I have a simple file that tries to connect to a database- <% Set RSDiscounts = Server.CreateObject("ADODB.Recordset") RSDiscounts.ActiveConnection = "Data Source=serverName;Initial Catalog=dbName.dbo;Integrated Security=True" %> When I run it, I get- error '80040e21' /filename.asp, line 3 Searching for the error code doesn't help...

Why does query select (1/2) * 100 return 0 instead of 50 in SQL server 2005

I would like to get 50 as the output instead of 0. ...

Hebrew encoding in sql server2005

i try this code in sql server 2005 declare @userName nvarchar(50) set @userName='איש2' print @userName but i get this ???2 what is the cause? it look like it replace the Hebrew char to "?" 10x ...

Import negative numbers with SSIS 2005

I'm importing a flat txt file into SQL Server 2005 using SSIS. The problem is that negative numbers between -1 and 0 in the txt file are in a format without leading zero, e.g.: -.15 If I insert such number into my database using plain INSERT syntax it works without complaining. However, SSIS reports an error if it encounter such number...

Converting all the DateTime Columns to SqlDateTime Columns in a Datatable

Hi, What I want to do is basically take any generic DataTable and then Convert all the DateTime columns into SqlDateTime Columns. (i.e if the datetime column value = datetime.MinValue then Set it to SqlDateTime.Null) Is there anyway I can do this without altering the original datatable (i.e withoutadding computed columns ) or having t...

Grouping by financial year and applying these groups as filters

Hi, I am looking to set up 6 groups into which customers would fall into: Non-purchaser (never bought from us) New purchaser (purchased for the first time within the current financial year) Reactivated purchaser (purchased in the current financial year, and also in the 2nd most recent year) Lapsed purchaser (purchased in the prior finan...

Java DataBase Connectivity Problem with MS SQL Server 2005 from a Remote Server

I am writing a java code to connect with MS SQL Server 2005. MS SQL Server is on Remote server windows server 2003. I am trying the following code but i am unable to establish a connection: import java.*; public class Connect { private java.sql.Connection con = null; private final String url = "jdbc:sqlserver://"; privat...

SELECT DISTINCT and ORDER BY

If I place DISTINCT keyword i get an error other wise it is working fine. ERROR: Msg 145, Level 15, State 1, Procedure SP_Products_GetList, Line 15 ORDER BY items must appear in the select list if SELECT DISTINCT is specified. ALTER PROCEDURE [dbo].[SP_Products_GetList] @CatID int, @CatName int, @IsNew bit, @InActive bit, @SortBy ...

which is the best collation for European + English language

HI There, i am developing for European languages and also for English, the string are stored as NVARCHAR in sql server 2005. so, which is the best collation to be used is "Latin1_General_CI_AS" covers all? there are variations as well like Latin1_General_CP1_CI_AS,Latin1_General_BIN,Latin1_General_BIN2 etc comments\suggestions apprec...

Optimized query to get min/max

I have data as Employee: id Name -------- 1 xyz 2 abc 3 qaz Employee_A: (Eid - employee table, title - title table) eid active type title ------------------------------ 1 1 1 1 1 1 2 2 1 1 4 3 2 0 3 4 2 1 2 2 2 0 ...