I have a ADO.NET/TSQL performance question. We have two options in our application:
1) One big database call with multiple result sets, then in code step through each result set and populate my objects. This results in one round trip to the database.
2) Multiple small database calls.
There is much more code reuse with Option 2 which i...
Background:
I have about 170 SSIS packages. A new requirement is that users from other workstations can run them from their command lines using dtexec.
Question:
To make this possible I'd like to set change the protection level to encrypt sensitive with password, and change the password in each package.
Is there a way to automate th...
I have my own type:
CREATE TYPE MyType AS TABLE
(
foo INT
)
and a function receiving it as a parameter:
CREATE FUNCTION Test
(
@in MyType READONLY
)
RETURNS @return MyType
AS
...
can it return MyType or only TABLE repeating MyType's structure:
CREATE FUNCTION Test
(
@in MyType READONLY
)
RETURNS @return TABLE (foo INT)...
I'm using Sybase 12.5.3 (ASE); I'm new to Sybase though I've worked with MSSQL pretty extensively. I'm running into a scenario where a stored procedure is really very slow. I've traced the issue to a single SELECT stmt for a relatively large table. Modifying that statement dramatically improves the performance of the procedure (and rever...
A location table record has two address id's - mailing and business addressID that refer to an address table.
Thus, the address table will contain up to two records for a given addressID.
Given a location ID, I need an sproc to return all tbl_Location fields, and all tbl_Address fields in one resultset:
LocationID INT,
...
Hello all... I have a table in one of my databases which is a queue of emails. Emails to certain addresses get accumulated into one email, which is done by a sproc. In the sproc, I have a table variable which I use to build the accumulated bodies of the emails, and then loop through to send each email. In my table var I have my body colu...
My ERP Vendor has the following trigger on a table:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[SOItem_DeleteCheck]
ON [dbo].[soitem]
FOR DELETE
AS
BEGIN
DECLARE @RecCnt int, @LogInfo varchar(256)
SET @RecCnt = (SELECT COUNT(*) FROM deleted)
IF @RecCnt > 150
BEGIN
RAISERROR (54010...
I have a query that returns one row. However, I want to invert the rows and columns, meaning show the rows as columns and columns as rows. I think the best way to do this is to use a pivot table, which I am no expert in.
Here is my simple query:
SELECT Period1, Period2, Period3
FROM GL.Actuals
WHERE Year = 2009 AND Account = '001-4000-...
hi, i've got 1 row with many columns:
col1|col2|col3|...
and i want to have 1 column with many rows, like that:
col1
col2
col3
..
...
How do you calculate Average Percentage Yield (APY) with T-SQL? Is there a system function to calculate APY or do I have to create one?
Note: APY = (1 + r/n )^n – 1 where r is the stated annual interest rate and n is the number of times you’ll compound per year.
...
Suppose I have a table (tblEmp) whose structure is like as under
Dept Emp
----- ------
d1 e1
d1 e2
d1 e3
d2 e4
d2 e5
d3 e6
If I need to bring the output as
Dept DepartmentSpecificEmployees
------ ----------------------------
d1 e1,e2,e3
d2 e4,e5
d3 ...
Hey there,
I looking for a way to dynamicly add a filter to my statment without using dynamic SQL.
I want to select all computers from a table, but when I pass a computer id to the sp, I want to get only this computer.
Actually I try this on
DECLARE @ComputerFilter AS INT
DECLARE @ComputerID AS INT
SELECT Computername
FROM Comp...
If I want to see which values from an Excel spreadsheet column don't match values in a table, I can easily create a table with Bulk Import. Is there a simpler way?
EG, I want to do a query like:
select into #temp from ('a', 'b', 'c') as 'Id'
select * from #temp where Id not in (select Id from MyTable)
...
I need to move a huge amount of data from a couple tables in an old database to a couple different tables in a new database. The databases are SQL Server 2005 and are on the same box and sql server instance. I was told that if I try to do it all in one shot that the transaction log would fill up. Is there a way to disable the transaction...
Compare these 2 queries. Is it faster to put the filter on the join criteria or in the were clause. I have always felt that it is faster on the join criteria because it reduces the result set at the soonest possible moment, but I don't know for sure.
I'm going to build some tests to see, but I also wanted to get opinions on which would ...
I'm not very fluent with SQL Server commands.
I need a script to restore a database from a .bak file and move the logical_data and logical_log files to a specific path.
I can do:
restore filelistonly from disk='D:\backups\my_backup.bak'
This will give me a result set with a column LogicalName, next I need to use the logical names fr...
I have a column called body, which contains body content for our CMS. The data looks like:
...{cloak:id=1.1.1}...{cloak}...{cloak:id=1.1.2}...{cloak}...{cloak:id=1.1.3}...{cloak}...
A moderately tweaked for readability example:
## h5. A formal process for approving and testing all external network connections and changes to the f...
I have 2 stored procedures usp_SP1 and usp_SP2. Both of them make use of insert into #tt exec sp_somesp. I wanted to create a 3rd stored procedure which will decide which stored proc to call. Something like:
create proc usp_Decision
(
@value int
)
as
begin
if (@value = 1)
exec usp_SP1 -- this proc already has insert into #tt...
I have a table as follows
> RowID SessionID EventID RequestedURL Date
> 1 m2jqyc45g 1 Start 24/03/2010 19:52
> 2 m2jqyc45g 1 ProductPage 24/03/2010 19:52
> 3 m2jqyc45g 28 BuyNow 24/03/2010 19:52
> 4 tjmvb55dc4dg 1 ProductPage 24/03...
I have a need to take backup of a SQL Server Db with tons of data in it and import into another environment for updating and testing. Since, i am not interested in the data, i just want to recreate the schema on my other server. There is an option called 'Generate Script', but is throwing errors running them on the target server.
Curio...