sql-server

PHP SQL-Server connection error.

I am trying to connect to sql server using php using following code: $myServer = "server"; $myUser = "username"; $myPass = "password"; $myDB = "test"; //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); Getting following error: Fatal error: C...

Look up to get not matched records with source and target fileds having nulls

Hi All I am developing a dimension table, the requiremnet is to insert all possible unique combinations of source attribute. step1: I took source with row_number() functions to get the duplicate records as row number step2: conditional split used to take onlt row == 1 so I am taking all uniqe possible records from source in the initia...

help in solving a problem in sql server

I have aquestions from you. Does SQL server have any features so we can limit a field to fill with just specific values? For example assume that you have a field named "Name" then we want SQL just let us to fill this field with the following values: "Bella", "Jack", "Rose". is there any featues to do it? please guide me. thanks ...

query to select distinct

Hallo Friends, I need a query to throw an error message on comparison with table temp_invoice. It should compare the field [Task resp#] , against the [PB-ID] field in PB_Responsbility table for customer = 3D temp_invoice format Concession Number [Task resp#] TH-123 12345 TH-014 98065 TH-12...

Is the growth of a SqlServer database an intensive operation?

Hi, we have a Sql 2005 database and we have set the growth of the data file to autogrowth, 'By 1 MB' We see that it does that approx every 10 minutes (its 9 GB now). Is it as simple as: just put it to 10 or 100, or are there other things to consider, or can we just leave it at this because it's just an easy operation? ...

sql server 2008 cursor implementation

I would like to know how cursor actually works in sql server 2008. For example, are the results held in memory as soon as the cursor is opened? or the results stored in an intermediate format, the real data is retrieved when fetch? Please also suggest some good books or blogs about sql server internals. Thanks. ...

SQL cell wise trigger

Hi, Can a specific cell wise trigger be created. Or Is IF UPDATE(COLOUM) where OTHER_COLOUM like 'JT' 's equivalent present in MSSQLSEVER2008 ? ---EDIT after getting 2nd answer--- IF not UPDATE(CurrentNo) --// Wanted to do like this : where series ='JT' return IF not EXISTS ( SELECT 'True' ...

Multiproccessing with DB connection

I have some processes with python gui application and i want to connect with them to sql server. i use the following modules form multiproccessing import pool import pymssql conn = pymssql.connect(host=host,user=user,password=password,database=database) for data in my_list : self.pool.apply_async(fun,data,conn) i it possible ...

Debugging SQL Server queries

I have a view which has started causing the following error: Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value 'R1500051' to data type int. The problem is, the query is quite big and complex (several sub queries, joins and function calls) and I have no idea where that error is actually coming from....

How to yield recursion in query? What is the use of "With" ? How it works internaly ?

Why this query is completed with error ? ;with tempData as ( select 32 as col1, char(32) as col2 union all select col1+1, char(col1+1) from tempData ) select * from tempData ...

Why to use "not null primary key" in TSQL?

I am seeing too frequently "not null primary key" in scripts creating tables in TSQL in blogs, articles, books, forums, here in SO, etc. For example, BING gives 630,000 results ((just in English) if to search against "not null" NEAR "primary key" "sql server": http://www.bing.com/search?q=%22not+null%22+NEAR+%22primary+key%22+%22sql+s...

create database in sql server 2005 express edition without Browser

I have an SQL server Express edition Instance and I need to create a database on it but I don't have the Sql Browser how can I do it other wise ...

Cannot create a row of size 8937 which is greater than the allowable maximum of 8060

We are getting this error on a table in our database: "Cannot create a row of size 8937 which is greater than the allowable maximum of 8060." The table consists of about 400 varchar(max) fields. We are, however, only inserting empty strings into these fields. The insert seems to work, however when using SqlXml to read the data or whe...

How to write select query for this?

I have column COMPONENT_AMOUNT(money) ,MONTH_FOR(int), YEAR_FOR(int) and COMPONENT_TYPE(int). I want to find the sum of amount according to condition. I have written my query like this but it solve my purpose. My purpose is that if one select Nov-2010 then it will sum the amount up to this selected month including all the month of 2009....

SQL Server query with null value

In my C# code, I have to do an SQL Query like this : context.ExecuteStoreQuery("SELECT * FROM MyTable WHERE Field0 = {0} AND Field1 = {1}", field0, field1) When field1 = null in c# and NULL in database this query doesn't work. (I have to use a different syntax with IS NULL) How can I correct this without make an if (in reality, ...

Map user to default schema in SQL Server 2005

I had a new DB and I created a new user (ElarabyGroup) owner for this DB. And when I tried to map this user for default schema but I did not the name of object in browse of objects window. Please any one help me ...

SQL Server multiple many-to-many join query

I currently have a one main table with multiple other tables associated with it via many-to-many joins (with join tables). The application using this database needs to have search functionality that will print out multiple rows matching specific criteria, including all the values in the join tables. The values from the join tables also n...

SELECT with multiple subqueries to same table

I'm using the same SQL pattern over and over, and I know there has to be a better way, but I'm having trouble piecing it together. Here's a simple version of the pattern, where I'm pulling back the student's information and the last book they checked out, if one exists: SELECT TStudents.*, BookName = (SELECT TOP 1 BookName ...

TimeStamp in SQL Server 2000

I have a table named Table1 which contains an ID and TimeStamp. Table structure ID TimeStamp 1 0x0000000000047509 But when I compare the combination of these fields, it always shows false. What is the reason for this? My Query is : DECLARE @ID int DECLARE @TimeStamp timestamp SET @ID = 1 SET @TimeStamp = 0x000000000004750...

executing multiple SQL scripts encoded in UTF-8

Hi, I use Visual Studio 2008 database project for managing my database scripts and version control. by default visual studio script templates are encoded in UTF-8 format. when I try to concatenate the scripts for database release (using the DOS command "type *.sql > dbscripts.sql") and run the concatenated script from SQL server manageme...