sql-server

SQL, remove appearances of a comma at end of the line.

My data looks as follows MyText ------- some text, some more text, even more text,, some text,,,, some text, some text,,, some text, some more text, even more, yet more, and again I would like to achieve: MyText ------- some text, some more text, even more text some text some text, some text some text, some more text, even more, yet ...

SQL Agent Job - Connection may not be configured correctly or you may not have the right permissions on this connection?

I'm getting this error when running an SSIS package through SQL Agent Failed to acquire connection "ORACLE ADO.NET". Connection may not be configured correctly or you may not have the right permissions on this connection. When I log on as the SQL Agent User and run the ssis package directly it is fine. When I then execute it through the...

SQL script taking long time to extract data

This is the script that is taking a very long time USE [r_prod] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Drew Borden -- Create date: 4/16/2009 -- Description: Procedure to populated subdivision extract table -- ============================================= IF EXIST...

TClientDataSet and big insert

In my application I use TADOQuery with select (MSSQL) and linked with it TClientDataSet. I have to insert about million records and ApplyUpdates. So what I see in the SQL Server Profiler? I see that for each inserted row we have 3 queries: sp_prepare of insert script, sp_execute it with some values and sp_unprepare. I want just to prep...

can we pass parameter to a view in sql?

Can we pass a parameter to a view in Microsoft SQL Server? I tried to create view in the following way, but it doesn't work: create or replace view v_emp(eno number) as select * from emp where emp_id=&eno; ...

SQL Server triggers

I'm creating a trigger in SQL Server after INSERT, UPDATE and DELETE. Is there a way to know inside the trigger code if it is running on the insert update or delete statement, because I need different behaviors on each case, or I need to create a trigger for each one of them. Thanks in advance, Paulo ...

Start Sql Server Agent

Hi all, just got the Sql Server 2008 enterprise edition, and i can't start the Agent xps service. i looked over surface area configuration and tried to change the service start mode from Disabled to Automatic(in the sql server configuration manger) and there i gen an error "the remote procedure cannot be complited" the error code is 0X80...

SQL Server Database Roles via SMO

I am trying to add new roles to a SQL 2005 database via the SMO assemblies. The Roles.Add method just does not seem to add the new role. I have my user account set as securityadmin and sysadmin. Below is the code extract that I am trying to use to set the new role: [assuming d has been set to a database object] Dim dr As New Da...

IF/ELSE Stored Procedure

Hi, Can anyone please point out what im doing wrong with this Stored Procedure please. I cant get it to compile and my software isnt giving any useful clues as to what is wrong with it. CREATE PROCEDURE web.createSubscriptions ( @Member_Id BIGINT, @Trans_type VARCHAR(100), @Payment_Status VARCHAR(100), @Payment_Date DATE...

Asp.net membership database

Hi all, I am novice in asp.net and, I have design a website which is having small database (MS sql server), which is working fine on server but for users login, I have given asp.net membership security, which is not working, because its database is still in the app_data file. Now, how can I transfer membership database on my existing web...

How to control access to a Stored Procedure in SQL Server?

I want to be able to have a Stored Procedure that can only be used from a particular page, without having to create a permissions / role for a user, when it is just a single stored procedure I want accessed in this way. For example I want to have a proc_GetCustomerItems stored procedure which takes the Parameter of CustomerID and then...

Testing a Data Pump

I have recently created a DataPump for connecting 2 SQL Servers together but it isn't working. Is there any way to test that the pump is working properly as I wish to eliminate from the list of possible things that may not be working? ...

SQL INSERT but avoid duplicates

I want to do some quick inserts but avoid duplicates into a Table. For argument's sake lets call it MarketPrices, I've been experimenting with two ways of doing it but not sure how to benchmark which will be faster. INSERT INTO MarketPrices (SecurityCode, BuyPrice, SellPrice, IsMarketOpen) SELECT @SecurityCode, @BuyPrice, @SellPrice, @...

SELECT max(x) is returning null; how can I make it return 0?

How do you return 0 instead of null when running the following command: SELECT MAX(X) AS MaxX FROM tbl WHERE XID = 1 (Assuming there is no row where XID=1) ...

Repository design problems

Hi everybody! I think i have some design errors in my ongoing web project (i'm using Linq2SQL implementing repository pattern) 1) Every repository creates its own DataContext (is this correct?should this be this way) For example: public class SQLPersonRepository : IPersonRepository { DataContext dc; public SQLPersonRepository(s...

How to get slowest queries on SQL 2005, without requiring compability change?

I was reading this fabulous list of sql dba scripts at http://www.sqldbtools.com/Scripts.aspx, not affiliated with them. And I want to run this query... select top 10 qs.execution_count, st.dbid, DB_NAME(st.dbid) as DbName, st.text from sys.dm_exec_query_stats as qs cross apply sys.dm_exec_sql_text(sql_handle) st order b...

Create a temporary table like a current table in SQL Server 2005/2008

How do you create a temporary table exactly like a current table in a stored procedure? ...

Adding Maintenance Plan In Sql Server With Commands

Hi all, there is a way using sql language or some C# library to add maintenance plan on sql server? thank you all. amit. ...

Web services and SQL Server 2005

Is it possible to set up SQL Server with a web service to receive and store data bypassing the IIS/ASP.NET layer altogether? I know it's possible to set up a web service via HTTP End Points and such to return requested data but I can't seem to find examples to show the opposite process. ...

Returning Output Param from SQL Connection

Is this possible or the right way to go about this (if you're not using a stored proc): conn.CommandText = "set @TotalPts = select SUM (pts) from cars where completedDate is not null and customerID = @customerID"; conn.AddParam("@customerID", customerID); conn.AddOutputParam("@TotalPts", SqlDbType.Int); ...