sql-server

Is SQL Studio part of SQL Server Express edition?

Is SQL Studio part of SQL Server Express 2005 edition? If not, how do you restore a database to the server if there is no Studio to use? ...

How to write a pseudo Code

Using VB.net, C# and SQL Server I want to write a pseudo for my application. pseudo code is like coding or flow chart...? Can any one provide a sample pseudo code for any type of application. ...

T-SQL Update Statment with ORDER BY

I am using SQL Server 2005. I would like to update fields like Order BY MatchId orders as below query. But updeted fields not order by MatchId. DECLARE @counter int SET @counter = 10008 UPDATE Matches SET @counter = MatchNumberCounter = @counter + 1 WHERE MatchId IN (SELECT TOP (232) MatchId FROM Matches WHERE LeagueStatueId =...

Html strip in asp.net

I have used a ckeditor in which user can submit data to the database in styles but when the data is populated in the datagrid then also it comes with same styles in IE but I want it to be in plain text when get populated. the function for populating the data is as follows: protected void LoadQA(int intQuestionId) { string strSelect...

Insert on single table caused deadlock.

I am using SQLServer 2005 and designed a DAO running insert sql like this: INSERT INTO eventsources (recevied_event_time_stamp, recevied_event_curve_name, recevied_event_curve_value, recevied_event_quote_date, total_time_for_event_processing, number_of_published_events{0}, triggered_curve, recevied_event_day) however, the system throw...

How to place negative value into brackets

i want to place negative value in bracket like -2000 to (2000) for that i made a which is converting -1361236.75886298 to (1.36124e+006) the function that i made for this is : ALTER function [dbo].[IsNegative]( @Number NVARCHAR (500) ) Returns nvarchar (200) as begin Declare @Number2 FLOAT set @Number2=Cast (@Number as float) Declar...

How to export query results to csv in Microsoft SQL Server Management Studio?

Hi, Trying to export custom query to csv file I wrote the following command: sqlcmd [-S myserver -d mydb -E -Q "SELECT column1 ,column_date, DATENAME(WEEKDAY, column_date) AS day_of_week ,distinc_events_count ,total_events_count ,event_duration FROM dbo.event_daily_stats ORDER BY column1" -o "D:\MyData.csv" -h-1 -s"," -w 700] but it ...

SQLServer join two tables

Hi guys, I've gotta question for you, I'm getting hard times trying to combine two tables, I can't manage to find the correct query. I have two tables: T1: 1column, Has X records T2: 1column, Has Y records Note: Y could never be greater than X but it often lesser than this one I want to join those tables in order to have a table with t...

Reading Data From Microsoft SQL Server into R

Does anyone know whether it is possible to read the data stored in MS SQL server from R interface? If it is I would be also thankful if anyone could show the way to do it. Thank you! ...

Calling As400 procedure in SSIS

HI All, I have created one simple stored procedure in AS400. It has only one input parameter and I compiled and created it successfully. Now I need to call this procedure in SSIS to move data from source to destination. Here my source is As400 procedure and destination is Sql server table.I have goggled lot to find how to call the proc...

WSDL on SQL Server gives HTTP status 505 Version Not Supported

I am a DBA, not a developer, so forgive me if this is a silly question. But we are having issues with a SQL Server 2005 Web Service end point. On the local network I am able to add the reference in Visual Studio 2010 with out any issues. It uses digest as the authentication scheme. However, when anyone tries to add the web reference on ...

How to update column with incremental value using tsql?

I wanna update first and last name of one table with incremental value. For example:- ID FirstName 1 Demo_01 2. Demo_02 3. Demo_03 4. And so on.... This table has 1000s of records. But for demo purposes we do not want to share real Name. So Please help how to update First Name with "Demo_ + Incremental value by one? ...

Why did this trigger change speed my query up?

Hi, I've been trying to solve a slow trigger problem and now that I have through trial and error, I still don't know what the original problem was. The query I'm running is the following: UPDATE tblA SET X = NULL WHERE X IS NOT NULL AND Z = 0 It updates around 30k rows. And the part of the AFTER INSERT, UPDATE trigger on tblA caus...

Is their an elegant way to track the modification of all columns of one table in SQL Server 2008

There is a table in my database containing 100 columns. I want to create a trigger to audit the modification for every update operation. What I can think is to create the update clause for all columns but they are all similar scripts. So is there any elegant way to do that? ...

Difference between PHP SQL Server Driver and SQLCMD when running queries

Hello all, Why is that the SQL Server PHP Driver has problms with long running queries? Every time I have a query that takes a while to run, I get the following errors from sqlsrv_errors() in the below order: Shared Memory failure, Communication Link Failure, Timeout failure But if I try the same query with SQLCMD.exe it comes ...

SQL: Need to return specific dates for sku's

Here is what i have: UPDATE webdev.tempdb.dbo.MediaResource SET Date_Min_Enabled = PRAH.DateCreated FROM FeedBack.dbo.Part_Resource_Associations_History as PRAH JOIN WebDev.DataWareHouse.dbo.Inventory as I on I.SKU = PRAH.PartNumber JOIN FeedBack.dbo.Part_Resource_Associations as PRA on PRA.PartNumber = I.SKU This only return...

Wrong order in Table valued Function(keep "order" of a recursive CTE)

Hello, a few minutes ago i asked here how to get parent records with a recursive CTE. This works now, but I get the wrong order(backwards, ordered by the PK idData) when i create a Table valued Function which returns all parents. I cannot order directly because i need the logical order provided by the CTE. This gives the correct order(f...

How to add surrogate key to related tables?

I need to add a auto-inc surrogate key to three tables in my data warehouse: Note: These are not the real table names JakMaster (JakMasterId, Date) (PK) Note: JakMasterId is varchar(60) JakToRoad (JakMasterId, Date) (FK) JakToBig (JakMasterId, Date) (FK) What steps should I take to add a surrogate key to these three tab...

Using Ncqrs fail when I tried to save second field

This is the error: Precondition failed.: !IsConfigured Cannot configure the environment when it is already configured. public static void BootUp() { var config = new StructureMapConfiguration((i) => { i.For<ICommandService>().Use(InitializeCommandService()); i.For<IEventStore>().Use(Initialize...

Complex editing on a gridview in C#

Hi all, I am working on an attendance system that has the following tables: Entry +---------+-----------+ + EntryID + EntryDate + +---------+ ----------+ Hour +---------+--------+---------+ + EntryID + InHour + OutHour + +---------+--------+---------+ With the following example data: Entry +---------+---------------------+ + En...