sql-server

ssis merge join more than 2 data sets

I'm working on an ssis package to fix some data from a table. The table looks something like this: CustID FieldID INT_VAL DEC_VAL VARCHAR_VAL DATE_VAL 1 1 23 1 2 500.0 1 3 David 1 4 4/1/05 1 5 52369871 2 1 25 2 2 ...

How to use optional parameter in stored procedure

I have a stored procedure which looks like CREATE PROCEDURE Update-all ( @RowID INT, @Parameter1 NVARCHAR(50), @Parameter2 INT ) As .... i will be passing @Parameter1 / @Parameter2 based on different conditions. if i don't pass @Parameter1 / @Parameter2 ,i am getting a error the stored procedure expects @parameter1/@pa...

Insert and Relate Records in Single SQL Query?

I am trying to copy data from an old database into a new one, and transform it to follow the new db structure. The old one looked something like this: Table 1: Id | Col A ---------- 1 0 2 8 3 7 4 1 In the new database, Table 1 now looks like this, where the data from col A is now in another table, and it's linked...

MS SQL server 2005 lock requests/sec rising linearly non-stop

While running an application load test, I am observing some weird behavior. Lock requests/sec counter is increasing in a linear fashion throughout the whole test (duration 12 hours, load levels off to a constant level within first 10 minutes). The value reached 6 million at 12 hours. There was no apparent impact to the response time of t...

xml document error when running a SQL Server Reporting services report

Hi, I have a SQL Server 2008 reporting services report which runs fine in preview mode using Visual studio 2008, but when I deploy it to the report server and run it there, it throws the following error. what does this error mean and how can I fix it? Thanks in advance. "There is an error in XML document (1, 170604). '.', hexadecimal val...

running 7-zip from a SQL script

is it possible to call 7-zip from a SQL script? basically i am extracting tables to csv and then packaging them into 7z files. I have installed 7-zip on the machine where SQL Server is installed and added it to the path, but this is not enough it seems. I get the following error when i try to run the script with xp_cmdshell '7z' is not...

SQL with clause dynamic where parameter

I have a tree-style database with the following structure: Table fields: NodeID int ParentID int Name varchar(40) TreeLevel int I would like to use a variable @NodeID in the first part of the with clause to don't get all the table just start from the piece I'm interested in (see where Parent=@ParentID and comment). with RecursionTe...

SQL Server Management Studio problem creating scripts of procedures

The stored procedure scripts that SQL Server Management Studio 2005 generates for me are like: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER OFF GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[APY_SP_ACH_Transmit_Finish]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' ... print...

Issue when running SQL Server 2005 SSIS Package on Remote Server

hi, i created a SSIS package on my development machine which simply: 1) Deletes records from weak table in database. 2) Loads file from filesystem into weak table in database. 3) The package is called from an asp.net page When i run the package manually on my machine it works, when the protection level is EncryptSensitiveWithUserKey. W...

SQL Server - sys.dm_exec_requests Issue

In SSMS 2008 I created a new query window and issued the following statement (notice I don't commit the transaction): Begin Tran Update Master.Part Set LastModifiedUser = 'me' I then open another new query window and entered the following query: Select * From sys.dm_exec_requests The DMV does not show the query from the first query...

SQL Server sp_ExecuteSQL and Execution Plans

I have a query which is superfast in SQL Server Management STudio and super slow when run under sp_ExecuteSQL. Is this to do with caching of execution plans not happening when run under spExecuteSQL? ...

problem with multi statement table valued function, what am I doing wrong?

Hi guys, I having problems with this function, seems like @idUsuario and @passCorrecto aren't getting any value, so, when I use this variables in the where clause I'm not getting any result data. ALTER FUNCTION [dbo].[login](@usuario varchar(20), @password varchar(20)) RETURNS @info TABLE (nombre varchar(70) not null, tipo varchar(30) ...

How can we set tables relations in SQL Server Express?

I have SQL Server Express 2008. How can I set a table's relations in it? ...

Migrating from Postgres to SQL Server 2008

I need to migrate a database from Postgres 7 to SQL Server 2008. I am familiar with the SSIS Import and Export wizard but I am stumped about how to define the data source or define the data provider. What is the best way to migrate Postgres to SQL Server, and how do I define data sources/drivers for postgres? ...

T-SQL UNION query to return items with highest and lowest rating from the same table

I want write a stored proc in T-SQL to return the top 5 most highly rated and the bottom 5 most lowly rated articles from an Articles table, determined by the 'rating' column. I was thinking of using a union on two selects but I'm not sure how to write it. ...

SQL show records that don't exist in my table variable

I have a table variable that holds orderID, UnitID and OrderServiceId (it is already populated via a query with insert statement). I then have a query under this that returns 15 columns which also include the OrderId, UnitId, OrderServiceId I need to only return the rows from this query where the same combination of OrderId, UnitId, an...

Execute Stored Procedure in a Cursor

I need to execute stored procedure sp_spaceused for all the tables in my database. I have used cursor for this, please find the below query.The thing is I need to generate report in a single result set. For the below query I'm getting different results. Declare @Name Varchar(500) Declare @GetName Cursor Set @Getname ...

sql to find non-printable characters in a string

Hi, one of my SQL queries is returning non-printable characters in the data because of which I get an error in the report. Please let me know how can I check if a string has a non-printable characters in T-SQL, so that I can find those rows and fix the data? Thanks in advance. ...

Fastest way to update 120 Million records

I need to initialize a new field with the value -1 in a 120 Million record table. Update table set int_field = -1; I let it run for 5 hours before canceling it. I tried running it with transaction level set to read uncommitted with the same results. Recovery Model = Simple. MS SQL Server 2005 Any advice on getting this done faster?...

Does the SQL Server clustered index replace the RID lookup "index"

When a table has a clustered index in SQL Server does that mean that all indexed queries will go via the clustered index? For example if I have a table with a single non-clustered index (indexing one column) and search for a row via that column it will do Index Seek -> RID -> Data row lookup -> Result But if I add a clustered index on ...