Creating New Transaction Query

Jun 15, 2007

I have a table with the following columns: Rtype, Amount, Refnumber, Color:
Here is what the table looks like:

RD 25 1 blue
AB 45 2 green
AC 25 3 purple
AD 34 4 blue
AE 25 5 pink

Now lets say I would like to create new transactions for all 'RD' Rtypes, but I would like to change the Amount to lets say, 99 for all of 'RD' types, but keep the same refNumber. For example, I want to create and insert a new transaction for RD, but with the amount 99, so that the row looks like this:

RD 99 1 blue

Where do I put in the query to change the Amount value? I do not wish to use the update function, because I actually want to create a new row. The query I am using, but not working is:

INSERT INTO EMPLOYEES(Rtype, Amount, Refnumber, Color)
SELECT Rtype, Amount, Refnumber, Color
FROM Employees
WHERE Rtype = 'RD';
Reply With Quote

View 1 Replies


ADVERTISEMENT

Creating A Transaction Log

Jul 9, 1999

o/s - win/nt 4.0
sqlserver 6.5

How do I create a tranaction log for an existing database?

Thanks........

View 2 Replies View Related

SQL Server 2008 :: Backup Device Creating Backups With A New Transaction Log For Each Day

Jun 19, 2015

Having a lot of problems with backup device creating backups with a new transaction log for each day. This is causing the backups to grow way to fast. Seems to be random with our clients. Created new device backups but getting same problem. A manual backup selecting overwrite all existing backup sets will fix it. But starts the cycle all over again.

View 9 Replies View Related

Error 8525: Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

May 31, 2008

Hi All

I'm getting this when executing the code below. Going from W2K/SQL2k SP4 to XP/SQL2k SP4 over a dial-up link.

If I take away the begin tran and commit it works, but of course, if one statement fails I want a rollback. I'm executing this from a Delphi app, but I get the same from Qry Analyser.

I've tried both with and without the Set XACT . . ., and also tried with Set Implicit_Transactions off.

set XACT_ABORT ON
Begin distributed Tran
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.TRANSACTIONMAIN
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.TRANSACTIONMAIN
set REPFLAG = 0 where REPFLAG = 1 and DONE = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.WBENTRY
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.WBENTRY
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.FIXED
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.FIXED
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.ALTCHARGE
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.ALTCHARGE
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.TSAUDIT
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.TSAUDIT
set REPFLAG = 0 where REPFLAG = 1
COMMIT TRAN


It's got me stumped, so any ideas gratefully received.Thx

View 1 Replies View Related

SSIS, Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Feb 22, 2007

I have a design a SSIS Package for ETL Process. In my package i have to read the data from the tables and then insert into the another table of same structure.

for reading the data i have write the Dynamic TSQL based on some condition and based on that it is using 25 different function to populate the data into different 25 column. Tsql returning correct data and is working fine in Enterprise manager. But in my SSIS package it show me time out ERROR.

I have increase and decrease the time to catch the error but it is still there i have tried to set 0 for commandout Properties.

if i'm using the 0 for commandtime out then i'm getting the Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

and

Failed to open a fastload rowset for "[dbo].[P@@#$%$%%%]". Check that the object exists in the database.

Please help me it's very urgent.

View 3 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Feb 6, 2007

I am getting this error  :Distributed transaction completed. Either enlist this session in a new
transaction or the NULL transaction. Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code. Exception Details:
System.Data.OleDb.OleDbException: Distributed transaction completed. Either
enlist this session in a new transaction or the NULL transaction.have anybody idea?!

View 1 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Dec 22, 2006

i have a sequence container in my my sequence container i have a script task for drop the existing tables. This seq. container connected to another seq. container. all these are in for each loop container when i run the package it's work fine for 1st looop but it gives me error for second execution.

Message is like this:

Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

View 8 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction. (HELP)

Jan 8, 2008

Hi,

i am getting this error "Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.".

my transations have been done using LINKED SERVER. when i manually call the store procedure from Server 1 it works but when i call it through Service broker it dosen't work and gives me this error.



Thanks in advance.


View 2 Replies View Related

Creating A Query In ASp.NET SQL

May 18, 2008

Hi, i have been able to create a query in asp.net in the sever explorer.
I want to create an statement as a new column.
In Access i would do it like this (Agg: [Scored]-[Against])
But how do i call a new column Agg in SQL and then tell it to take Against away from Scored?

View 3 Replies View Related

Help Creating Query

Apr 1, 2008

SELECT Name, TagID,
(SELECT COUNT(TagID) AS Expr1
FROM dbo.mw_PagesTagMap
WHERE (TagID = tag.TagID)) AS TagWeight
FROM dbo.mw_Tags AS tag




This query works exactly how I want it to.
I would like to modify this to NOT return any column that has a TagWeight of 0

SELECT Name, TagID,
(SELECT COUNT(TagID) AS Expr1
FROM dbo.mw_PagesTagMap
WHERE (TagID = tag.TagID)) AS TagWeight
FROM dbo.mw_Tags AS tag
WHERE (TagWeight <> 0)
I thought this would do it but I'm getting an error "invalied column TagWeight".
How would I get this to work?

View 3 Replies View Related

Need Help Creating Query

Jul 23, 2005

I am working with employee schedules. Each schedule is comprised ofsegments (shift, lunch, break, training, etc.) that have rankings.Each record has the employee id, the date the shift starts, the startand end time of each segment, the duration,the segment type and itsrank. The start and end times of the schedules can overlap, but thesegment that has the higher rank takes precedence.As a simple example, an employee working 8a-5p will have two records.The shift segment from 8a-5p and a lunch segment from 12p-1p. Thelunch ranks higher so, even though the shift goes from 8a-5p, from12p-1p, the lunch takes precedence.What I'm trying to do is build a query that will collapse the segments.So given the example above, I will now have three records: shift8a-12p, lunch 12p-1p, shift 1p-5p.I have been racking my brain but I just can't figure it out.Ultimately, a programmer in my office will display this in a bar chartformat with each segment type having its own color. I'm trying to do asmuch of the work in SQL so he doesn't have to calculate this stuff inthe code.Any help would be appreciated.Thanks.Angela

View 5 Replies View Related

Need Help Creating A Query..

Apr 15, 2008

Hey all, am a bit new to SQL so excuse my ignorance I am wanting to create a query that uses 2 parameters and returns 20 random records that meet the criteria.
One of the parameters is stored in a different table to the one im querying, and the other is a selection made by the user on a VB form.. If its any help, my table schema is:

QUESTION: (QuestionID, Text, Answer, Category, AbilityLevel)

I need AbilityLevel to match a variable stored in the VB form and Category to match a value selected by the user from a combo-box.

I really dont know where to begin with this so any help would be greatly appreciated!

Cheers,
Adam.
P.S. apologies if this is too VB related to belong in this forum!

View 5 Replies View Related

Transaction Query

May 6, 2008

CREATE PROCEDURE orders
AS

DECLARE @number int

set nocount on
begin transaction
Select @number = (Select lastNo from Computetab)

Update Computetab
Set Computetab.lastno = (@number+1);

SELECT Computetab.lastno from Computetqb
commit
GO

this is supposed to reutrn a new order id everytime but today for some reason it gave same ord# to two different people trying to save a new order

I thought begin transaction will take care of it any suggestion please.........

thanks a lot!!

View 8 Replies View Related

Query Regarding Transaction Log

Feb 26, 2008

HI


My actual Need: I need see what are the tables in database which got updated(either by insertion or update) by getting some information about tables not by using triggers.

1.I figured it out that can be done by using transaction log.as given below:

I need to access data recorded in my transaction log.but,when i try to open that file i am able to see only junk values.
Can anybody suggest me how to read that data by using any sql query or using any 3rd party application.

2.Can i get to know this information about this using any of system tables its well in good.

View 12 Replies View Related

Error In Creating Query

Aug 11, 2000

Hi,

I don't see what's wrong with this command.
>>
Create View BCPOutBatchWeightTaiwan AS
Select *
from batchWeight a JOIN Geography b
ON a.GeographyPtr = b.GeographyPtr
where b.countrycode = 'tw'
<<
I get the following error if I try to create it.
>>
Server: Msg 4506, Level 16, State 1, Procedure BCPOutBatchWeightTaiwan, Line 2
Column names in each view must be unique. Column name 'GeographyPTR' in view 'BCPOutBatchWeightTaiwan' is specified more than once.
<<

But it runs fine if I run only th 'Select' part of the command
without 'CREATE' line.

Any help is appreciated.

Thanks.
Ranjit

View 1 Replies View Related

Error When Creating DMX Query

Nov 8, 2006

On screen states [Error loading mining model metadata: No Metadata found]

and on the functions states [Error loading functions: no functions found]

This also occures when trying to use the Data mining wizard, it will just not respond.

Have deleted and removed all references to SQL2005 Standard and reloaded and still get same errors

Could someone please advise, have sent errors to Microsoft with no responce back yet.



View 1 Replies View Related

Problem In Creating Query?????

Nov 28, 2007

Hi
i have a table with 2 columns region and Ddate .
I want total records for a particular region.
I am creating query as follows:

SELECT Region, COUNT( * ) FROM Market_data
GROUP BY Ddate

The above query is generating error.
So how can i create the query????????????

View 1 Replies View Related

Creating A Formated SQL Query And Email It

Feb 4, 2002

I need to create a "simple" sql query but have it formatted and then emailed
to individuals. I am trying to convert over from Oracle but I am having a
hard time getting the query to be formatted the way I want. Here is the select statement I tried to use with no luck with xp_sendmail:

SELECT ALARM ID, TIMESTAMP as TIME, CLASS, RESOURCE, P, L, F, ALARM_MESSAGE
FROM ALARM_LOG WHERE ([TIMESTAMP] < GETDATE() - 1) ORDER BY [TIMESTAMP];


Here what the output should look like with the column headers underlined and
then the column data (notice the column heading ALARM MESSAGE is on the
next line before any data):

ALARM ID TIME CLASS RESOURCE P L F
-------------------- ----------- ----- ---------------- - - -
ALARM_MESSAGE
-------------------------------------------------------------
B3_TEMP_ALM 02-02@11:21 ALARM BUILDING3_TEMP N G G
BUILDING 3 TEMPERATURE ALARM, CALL SECURITY.

B5_TEMP_ALM 02-02@11:22 ALARM BUILDING5_TEMP N G G
BUILDING 5 TEMPERATURE ALARM, CALL SECURITY.


How can I run the query and have it formatted and emailed out?
What is the best way to accomplish this?

Thank you,

Mark

View 1 Replies View Related

Creating Table From Query Results

Feb 6, 2014

I have this query;

select c.name
FROM sys.tables AS t
INNER JOIN sys.columns c
ON t.OBJECT_ID = c.OBJECT_ID
where t.name= 'Hosea_tblDATA_NOTES'and c.is_identity = 0
order by column_id

and I get these results;

NOTE_ID
NOTE_DESCRIPTION
NOTE_TEXT
NOTE_STATUS
NOTE_STARTDATE
NOTE_ENDDATE
NOTE_AUTHOR
NOTE_LASTUPDATE

I was thinking if it is possible to create a table from the results of this query, my table name(in this case 'Hosea_tblDATA_NOTES') will be a parameter, that whatever table name I pass, with the results I get I will be able to create another table, assuming all data types are varchars, but it should be generic.

I want to create a new table with the about of that query, that output has to be my columns.

View 1 Replies View Related

Creating A DB To Query Game Server

Mar 3, 2008

Im just wondering if it is possible to use a SQL DB to query game servers, Im very new to SQL, an if it is possible please lead me in the right direction on start this.

Thanks,

View 8 Replies View Related

Creating Expressions With The Query Builder

Sep 18, 2007

Hello,

I have a question about using the query builder, or just straight sql, to create expressions. My first example caused the query builder to generate a query configuration error:


Expression: EIM_REQUISITION_DETAILS.EST_UNIT_COST * EIM_REQUISITION_DETAILS.REQRD_QTY AS COST


Syntax error: Expecting "," or "FROM" after column alias or "*"

Initially I thought I was dead in the water but then I decided to just run it anyway and it worked! I got my cost. OK so fine the query tool doesn't recognize some sql expressions. Because I am trying to make a large flat file I thought I'd concatenate 2 fields to generate a recognizable requisition, which everyone knows is the year followed by a hyphen then the req number:



My old Access query had this: Req: Right([REQ_YR],2) & "-" & [REQ_NO]

and I tried to change it to this: substring (EIM_REQUISITIONS.REQ_YR from 2 for 2) || '-' || EIM_REQUISITIONS.REQ_NO AS REQ

So apparently my older sql book doesn't have the syntax right. Since I plan to do more of this could someone point me to a reliable book or site that could help me with sql syntax?

Thanks,
Dana




View 3 Replies View Related

Truncate Transaction Log Through Sql Query Analyser

Oct 20, 2005

Hi guys

My website is in asp and sql2000. My problem is the ISP gave access to database through query analyser. some days the transaction log is growing too high. so i want to clear it. i call up them and clear it. My question is can truncate the log file through query analyser ?
I had limited access to database.

Jini

View 11 Replies View Related

Creating A Sequential Row Number In A Query Resultset --- Is It Possible?

Feb 17, 2005

Hello everyone,

I have a stored procedure that supplies rows for a front-end DataGrid that allows custom paging. The stored procedure must return the requested "page" of rows as identified by a sproc argument. Currently, I'm loading the the query's result set into a temporary table that has an identity column as primary key. I then run a second query against the temp table that uses the identity column value to strip out the requested "page" of rows and return them to the front-end DataGrid.

I'd like to eliminate the temporary table. To do so I would need to create the equivalent of an identity column in the query's sorted results and reference this value in the WHERE clause in order to return only the requested rows.

Does anyone know of a way to generate a sequential number (starting at 1) within a query (and after the rows have been sorted by the ORDER BY)? I don't think this can be done but I put it out for those who may know better.

Thanks for your help. If you know this is impossible, that would be helpful feedback as well.

BlackCatBone

View 3 Replies View Related

Creating A Query Showing File Not Existing

Jan 16, 2008

This is a SQL question while using Microsoft SMS.

I am trying to write a SQL query looking for a specific file in a specific directory. If the File does not exist, then I want it to display.

here is the Code that I have for it that shows that the file exists... how do I make it show that the file doesn't exist?... what am I doing wrong?

Thanks for all your help in advance!

**********************************

SELECT TOP 100 PERCENT SYS.Netbios_Name0, SYS.User_Name0, SF.FileName, SF.FileVersion, SF.FileSize, SF.FileModifiedDate, SF.FilePath,
SYS.Operating_System_Name_and0
FROM dbo.v_GS_SoftwareFile SF INNER JOIN
dbo.v_R_System SYS ON SYS.ResourceID = SF.ResourceID
WHERE (SF.FileName = 'UdaterUI.exe')
AND (SF.FilePath = 'C:Program FilesMcAfeeCommon Framework')
OR
(SF.FileName = 'UdaterUI.exe')
AND (SF.FilePath = 'c:Program FilesNetwork AssociatesCommon Framework')
ORDER BY SF.FileVersion, SYS.Netbios_Name0

View 1 Replies View Related

SQL Server 2012 :: Creating XML File From Query?

Apr 15, 2015

What I am trying to recreate is:

<value version="5" type="database">
<name>master</name>
<server>servername</server>
<integratedSecurity>True</integratedSecurity>
<connectionTimeout>15</connectionTimeout>

[Code] ....

with this query:

SELECT
'version="5" type="database"' AS 'value',
'master' AS 'name',
LTRIM(RTRIM(([Server Name]))) AS 'server',
'True' AS 'integratedSecurity',

[Code] ....

BUt my output is not correct, it is creating this:

<value>
<value>version="5" type="database"</value>
<name>master</name>
<server>ServerName</server>
<integratedSecurity>True</integratedSecurity>

[Code] .....

So my question is how to I get <value>version="5" type="database"</value> as the first 'value' node?

I've tried multiple ways, but no success.

View 2 Replies View Related

T-SQL (SS2K8) :: Creating Range Between Values In Query?

Apr 26, 2015

On a new project i need to create possible ranges between a specific interval.

suppose i have this main product:

main product : LY E67F

Also, in first level i have a table classify by Group depending on Intensity.

table group
Group intensity
AA 1120
AB 1400
BA 1800
BB 2240
CA 2800

I need to create these diferent options:

1 option : AAAB or AABA or AABB or AACA
2 option : ABBA or ABBB or ABCA
3 option : BABB or BACA or BBCA
or beginning from the end
1.option CABB or CABA...
or beginning from the middle
1.option BBBA or BBAB
and so on.

I fact, i need to find all available options possibles to build article code, like a matrix.

View 7 Replies View Related

Creating SELECT Query Which Involves Getting FIRST Occurrence

Apr 25, 2014

I have a problem creating a SELECT query which involves getting the FIRST occurrence, the SUMS and the LAST occurrence of a selected row. I have two tables A and B which has the following data:

Table A

----------------------------------------------------------------
|Item ID | Item Name | Item Description | Current Quantity |
----------------------------------------------------------------
----1------------Bolts-------------35"----------------20
----2-----------Paint----------GOLD Paint------------30
----3-----------Screws------------30"----------------40
----------------------------------------------------------------

and Table B

--------------------------------------------------------------
|Log ID | Item ID | Beginning | Add | Less | Ending | Date |
--------------------------------------------------------------
---1---------1----------30-------0-----10------20------04-04
---2---------2----------40-------10----10------40------04-04
---3---------3----------50-------5-----10------45------04-04
---4---------1----------20-------0-----0-------20------04-05
---5---------2----------40-------0-----10------30------04-04
---6---------3----------45-------0-----5-------40------04-04
-------------------------------------------------------------

and I have two datetime pickers, one FROM date picker and a TO date picker If a user selects FROM 04-04 TO 04-05...I want a select statement which will select the Item Name and Desc, the BEGINNING QUANTITY (in reference to the FROM DATE), the SUM of Adds and Less and the ENDING QUANTITY (in reference to the To Date) and then group by their Item ID

In this case, it will generate a table like this

----------------------------------------------------------
Item Name | Item Desc | Beginning | Add | Less | Ending |
-----------------------------------------------------------
--Bolts---------35"---------30---------0-----10-----20
--Paint-----Gold Paint------40---------10----20-----30
--Screws-------30"---------50---------5-----15-----40

"SELECT A.Item Name, A,Item Desc, B.Beginning=(select B.Beginning from Table B where A.Item ID = B.Item ID AND Date = From Date), SUM(B.ADD), SUM(B.LESS), B.Ending=(select B.Ending from Table B where A.Item ID = B.Item ID and Date = To Date) WHERE A.Item ID = B.Item ID and Date(B.Date)>From Date AND Date(B.Date)< To Date group by B.Item ID order by A.Item Name, Item Desc"

My query returns the right Item Name, Desc, the Sum of Add and Less.My problem is that I can't get the value of my beginning and ending.I think I have a problem in A.Item ID = B.Item ID. As I tried a fixed value condition, (B.Item ID = 2), it will get the right result), I'm guessing the program is not getting A.Item ID.

View 1 Replies View Related

Creating Table From Query Analyzer Gives Error

Oct 25, 2005

Hi,

I have the TAMCreate.sql file which contains the script to create all tables in the Database TAMaintenance. Its created and used in the SqlServer 2000. But i have only SqlServer 7. From the script i copy and paste each table and created upto 7 tables without any problem, when i create the 8th table i get the following error the code for the table

CREATE TABLE AA_Branch_Master(
Branch_Code varchar(15) CONSTRAINT PK_AA_Branch_Master1 PRIMARY KEY,
Branch_Name varchar(50) NOT NULL,
Branch_Opened datetime NOT NULL,
Branch_Location varchar(50) NOT NULL,
Branch_Province varchar(25) NOT NULL,
Branch_Incharge varchar(50) NOT NULL,
Branch_Remark varchar(150),
Branch_Status BIT(1))
go

Error:
Server: Msg 2716, Level 16, State 1, Line 1
Column or parameter #8: Cannot specify a column width on data type bit.

In the same way i have get the error or another table, rest of the tables are created successfully.

the code for the table

CREATE TABLE AA_Supplier_Master(
Supp_Code varchar(15) CONSTRAINT PK_AA_Supplier_Master1 PRIMARY KEY,
Supp_Name varchar(100) NOT NULL,
Supp_Address varchar(150) NOT NULL,
Supp_Contact_Person varchar(50) NOT NULL,
Supp_Paymode varchar(25) NOT NULL,
Supp_Tel1 varchar(25),
Supp_Tel2 varchar(25),
Supp_Fax varchar(25),
Supp_Postbox varchar(15),
Supp_Postal_Code varchar(15),
Supp_City varchar(50) NOT NULL,
Supp_Country varchar(50) NOT NULL,
Supp_Status BIT(1))
go

Error:
Server: Msg 2716, Level 16, State 1, Line 1
Column or parameter #13: Cannot specify a column width on data type bit.

Thankyou,
Chock.

Chock

View 1 Replies View Related

Creating A Query That Access Multiply Databases

Dec 10, 2007


Dear Readers,
Is it possible to create a query that access multiple sql express databases? Or is it possible to link a table in one database from another?

View 1 Replies View Related

Creating A View Form A Sequel Query

Apr 18, 2008

I've written a Union query that joins 16 different tables. I need to somehow make this into a permanent view so that i can query directly from excel to extract specific data - i guess i can set up excel to pull straight from this view then ?

I'm used to running excel VB code to SQL via Access (linking access up) but want to cut out the middleman now.

Any ideas ?

An example of the Union Query i have built is below :


SELECT[Vendor No_],[Posting Date],[Purchase (LCY)],[Buy-from Vendor No_],[External Document No_],[IC Partner Code]

FROM [NAV402].[dbo].[TESTCO Sweden$Vendor Ledger Entry]

WHERE[Posting Date]>='20070701' AND [Vendor No_] LIKE 'ZX%'

UNION

SELECT[Vendor No_],[Posting Date],[Purchase (LCY)],[Buy-from Vendor No_],[External Document No_],[IC Partner Code]

FROM [NAV402].[dbo].[TESTCO Taiwan$Vendor Ledger Entry]

WHERE[Posting Date]>='20070701' AND [Vendor No_] LIKE 'ZX%'

UNION

SELECT[Vendor No_],[Posting Date],[Purchase (LCY)],[Buy-from Vendor No_],[External Document No_],[IC Partner Code]

FROM [NAV402].[dbo].[TESTCO US$Vendor Ledger Entry]

WHERE[Posting Date]>='20070701' AND [Vendor No_] LIKE 'ZX%';


Thanks for any help you can give me.

PID

View 3 Replies View Related

Wrapping Query Batches In A Single Transaction.

Jul 23, 2005

I have a query batch "update" script that upgrades my users database from,say version 0 to version 1, or from version 1 to version 2. I would like toknow how I can wrap the entire script in a transaction, so that either thewhole thing succeeds or none of it does.For example:BEGIN TRANSACTION.......... Alter some tables.....GO.......... Alter a stored procedure.....GO.......... Create a new stored procedure.....GOCOMMIT TRANSACTIONorROLLBACK TRANSACTIONGO(how do I get to the "ROLLBACK TRANSACTION" if an error occurs in the updatescript?)

View 2 Replies View Related

Transaction Report By Weekly----Plz Help To Write Query

Nov 30, 2007



Hi Guys,
I am generating Transaction Activity report,which should get data by weekly.Report shold look like this.






W1
W2
W3
W4
W5
W6

OKC
79
38
50
76
35
47

NFL
0
0
45
43
33
28

LA

5

12

10

0

0

10

Total
79
38
95
119
68
75


Iam passing 3 parameters @startdate,@enddate,@Market. when i select one Market(OKC/NFL/LA), report generating properly, but when i passing 3 markets values(OKC,NFL,LA), iam getting wrong report,report format is not correct.I used Cross tab for generating this report.Result lam getting like this.













W37
W38
W39
W40
W41
W42
W43
W44
W45

OKC
80









OKC

38








OKC


95







OKC



119







OKC




68





OKC





75




OKC






74



OKC







70


OKC








59

OKC










OKC










LA










And i wrote query like this,

select m.Market_name as Market,'W'+datename(ww,ut.creation_date) as Week,count(ut.transaction_id) as Count
from POS.DSC_TRANSACTION_STATUS_VL ts inner join POS.DSC_USER_TRANSACTION ut
on ts.transaction_status=ut.transaction_status inner join POS.RETAIL_LOCATION rl
on ut.rl_number=rl.rl_number inner join POS.BILLING_MARKETS bm
on rl.bm_code=bm.bm_code inner join dbo.Market m
on bm.market_id=m.market_id
where (ut.creation_date between @startdate and @enddate) and m.market_name IN(@Market)
group by m.Market_name,ut.creation_date
order by m.Market_name desc

Could you please some one help me to get this correctly.



Thanks in advance


Thanks
San

View 2 Replies View Related

Creating Tables In SQL Server Via Query Analyzer With Relationships

Jun 7, 2005

I've been searching around for some info on how to set this up, but with no luck.I need to have a .sql file that will set up a few tables and these tables will have relationships and contraints.I can do this by hand in enterprise manager, but need to set up some procedures that will do the same thing.For instance, I can create the tables just fine.....CREATE TABLE students ( sId int NOT NULL PRIMARY KEY,        studentId varchar(50) NOT NULL,               course varchar(50)              )
CREATE TABLE courses  ( cId int NOT NULL PRIMARY KEY,        course varchar(50) NOT NULL,               sco varchar(50)              )But, I need to set up relationships in there somehow.Once student may have many courses (one to many) and one course may have many sco's (one to many) SCO would be another table.Can someone point me to a good link that would show how to complete these procedures?Thanks all,Zath

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved