Sunday 15 July 2012

tsql - combining a multiple queries into a single query (in SQL Server, with variables?) -


I want to apply the following query to two large circ_slip values ​​('payment' and 'refunds'). Remove from the address

then I added the following line at the beginning and then the original query copied three times, respectively Replace two examples of 'discount' with 'payment' and 'refund'.

  declare @copy_loc varcha r (7), @ nuilk varchar (7) @copy_loc = select 'copy location' @new_loc = 'Select new status'  < / Pre> 

I also have two selected variable statements (@copy_loc and @new_loc) because they have already been declared.

Any ideas on why it does not work for me? I do not have to say I would be very appreciative that I am quite new in SQL.

** Edit: By "Not working" I mean that the query ran away without errors but he There was no change in the situation. Edit second: I think the problem can be with the "go" command. To work in the variable, I want to 'go' from my three repeated questions. I need to delete I

notification @ cop_lak and @new_loc as defined by varchar (7) But you're putting 12 characters inside them. They are sorted and will not match the fields in the table. Make vertures (50) Do not worry, it will not use much of the space.

No comments:

Post a Comment