sql-server

Example php code for connecting and getting a sql stored proceedure

Can any one give The Example php code for connecting and getting a sql stored proceedure ...

Change Data Capture Question(s)

I'm trying to get up to speed on CDC by using it to create a very simple replication process. Let's say I have CDC set up for tables 'A' and 'B', which happen to have a FK relationship where 'A' is the parent and 'B' is the child. I want to replicate changes to these two tables to another DB. I'm thinking of creating an SSIS package (or...

Facing error with BCP utility?

I am getting the following error: SQLState = S1000, NativeError = 0 Error = [Microsoft][ODBC SQL Server Driver]Unable to open BCP host data-file NULL while using this bcp utility bcp "select * from database1.dbo.table1" queryout "c:\result.txt" -c -S10.10.10.100\dev -Usa -P123456 -t! Please check. ...

SQL: Counting Problem relating to two tables

I have a table with columns : Sku, Count in another table there are sku's with different images, so in this table one sku is repeated several times with multiple file extensions, what i need to do is to count the number of images that a sku has in the second table and then update the count column in the first table with that number. I w...

Need help tracking down sporadic "Unable to serialize the session state" server errors.

We have been receiving reports of the following server error periodically from users. [OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.] [HttpException (0x80004005): Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session stat...

finding the start day (Monday) of the current week.

Looking for a SQL query/queries that would determine the start day (Monday) of the current week. Example: If today is -> then the start of the week is Sat Oct 09, 2010 -> Start of the week is Monday Oct 04, 2010 Sun Oct 10, 2010 -> Start of the week is Monday Oct 04, 2010 Mon Oct 11, 2010 -> Start of the week is Monday Oct 11, 2010 Tu...

Help for solving a problem in a SQL Server assignment

Hi, I have created the following code so as to insert into two tables Users and Roles: -- to insert into the Users table declare @u int set @u = 1000 while @u <= 1200 begin insert into Users(UserID, Username, [Password], Email) values(@u, 'Username'+CAST(@u as varchar(4)), 'pass'+CAST(@u as varchar(4)), ...

Can I "join" across datasources in SSRS?

I've got two datasources, one Oracle and one Sql Server. Due to circumstances that predate me (as in it was like this when I found it) some columns in the Oracle database contain PKs from lookup tables in the Sql Server database. I am attempting to create a Sql Server Reporting Services report that will combine data from both the Oracle...

JPQL: How to include Forward Slash in Query String?

How do you properly escape a '/' forward slash in a JPQL query string? If I do this: LOCATE('/', REVERSE( ... I get: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query However, if I do this: LOCATE('\\', REVERSE( ... Everything is fine. So, how do I include the forward...

SQL And NULL Values in where clause

So I have a simple query that returns a listing of products SELECT Model, CategoryID FROM Products WHERE (Model = '010-00749-01') This returns 010-00749-01 00000000-0000-0000-0000-000000000000 010-00749-01 NULL Whitch is correct, so I wanted only get the products whose CategoryID is not '00000000-0000-0000-0...

How to pass parameter into stored proceedure from php

Hi I have a stored Proceedure 'spGetOrderByID' in the sql server. Which gives a record according the given order id. And the stored proceedure is working fine , while i trying in the sql server. This is the php code iam using $this->_connectionString = mssql_connect($host, $username, $password) or die("can't connect to server1"); ...

How to generate a new Guid in stored procedure?

Hi, I currently have a stored procedure in which I want to insert new rows into a table. insert into cars (id, Make, Model) values('A new Guid', "Ford", "Mustang") So the primary key 'id' is a Guid. I know how to create a new Guid in C# code but within the stored procedure I'm unsure how to generate the new Guids for the primary key v...

Creating a SQL Server trigger to transition from a natural key to a surrogate key

Backstory At work where we're planning on deprecating a Natural Key column in one of our primary tables. The project consists of 100+ applications that link to this table/column; 400+ stored procedures that reference this column directly; and a vast array of common tables between these applications that also reference this column. The ...

Managing SQL Server connected to existing DotNetNuke website

Sorry if this question isn't "programmery" enough. Before my time at the company they paid for a very expensive website written in asp.net and dotnetnuke. Absolutely terrible but there's very little that can be done about that now. They won't give us access to the SQL Server for some bizarre reason but they've given us FTP access. Is th...

How can I make SQL Server return FALSE for comparing varchars with and without trailing spaces?

If I deliberately store trailing spaces in a VARCHAR column, how can I force SQL Server to see the data as mismatch? SELECT 'foo' WHERE 'bar' = 'bar ' I have tried: SELECT 'foo' WHERE LEN('bar') = LEN('bar ') One method I've seen floated is to append a specific character to the end of every string then strip it back out for m...

Update all SQL NULL values in multiple columns using Column level WHERE clause?

We have a database with a bunch of wide tables (40-80 columns each) and just found a bug that introduced NULL values into about 500 of the records. The NULL values can appear in any of the columns (all are integer columns, see image below) but these NULL values are causing issues with one of our reporting systems that cannot be changed e...

Error Configuring Reporting Services in Team Foundation Server 2010 post install

We are configuring SQL Server Reporting Services on an existing installation of TFS 2010 RTM. After configuring the Warehouse, Analysis Services and Reports tab in the TFS Administration Console, I get the following error: "Failed to add BUILTIN\Administrators account to the TfsWarehouseDataReader role on the Tfs_Warehouse relational da...

Reading SQL Analysis Services Metadata

I have a number of objects in my SSAS cube, many of which were created to be invisible. For example: CREATE MEMBER CURRENTCUBE.[Measures].[Latency Backcolor] AS CASE WHEN [Average Latency] > [Web Alert] THEN 6384849 WHEN [Average Latency] > [Web Warn] THEN 4577517 ELSE IIF ( [measures].[Query count] > NULL, 14876123, null) END, VI...

Studio Express connect failed (SQL Server 2008)

I got this error A network-related or instace-specific error occurred while establishing a connection to sql server . the server was not found or was not accessible. verify thai the instance name is correct and that sql server is configured to allow remote connections. (privider: Named Pipes Provider,error:40...

SQL Query to show multiple entries and its count

I got a table like this (just look at Col1 and Col2) ID Col1 Col2 Col3 1 1a 2b vewva 2 1a 2b ds33 3 1c 2d sadp 4 1c 2e c2w 5 1c 2d 2309v 6 1d 2f 2fd3 7 1c 2d 23d3 I need to find duplicates in (Col1, Col2). What I need is some output like this: 1a 2b -...