Skip to content
Advertisement

Combining different SQL requests but they all have same WHERE

I have lots of requests, but they always have the same WHERE, I done request to copy a character by typing his name from a table, so it copy the data from other tables (sometimes need to delete and copy, sometimes only update), but if I want to copy someone’s character, I have to type the names 7 times in total, and I wish I could type it once and it change for all

Here are the different requests:

request to delete all rows from “samymewtu” and insert all rows by copying someone else, here “myths”

Here is the same but for the bank

Here is to copy stats, but it update the row since there is only one and I keep the characterId

There are some others but I think you get the idea, everytime I need to enter the c1.name=’samymewtu’ and the c2.name=’myths’

Advertisement

Answer

In SQL Server, you can use variables make a scriptquery dynamic.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement