HI Experts,
I have same table structures in two database and one master table which contains Table id, Table name,primary key, data type of primary key. i have to comapare
Tables in both tha database and as per result i have to do insert,update or delete.
for that i have written query :
DECLARE @rowcount_maste rtable FLOAT
SET @rowcount_maste rtable = (select count(*) from master_table)
DECLARE @TABLE_ID float,
@TABLE_NAME varchar (100),
@primary_key varchar (100),
@Primarykey_DAT ATYPE varchar (50),
DECLARE @COUNTER FLOAT
SET @COUNTER = 1
WHILE (@Counter <= @rowcount_maste rtable)
Begin
SET @TABLE_NAME = (SELECT TABLE_NAME FROM MASTER_TABLE TABLE_ID = @COUNTER)
SET @primary_key = (SELECT primary_key FROM MASTER_TABLE WHERE TABLE_ID = @COUNTER)
SET @Primarykey_DAT ATYPE = (SELECT Primarykey_DATA TYPE FROM MASTER_TABL WHERE TABLE_ID = @COUNTER)
--In below line i want to declare a variable and datatype should be same as what we got from master table so that i can use this @MAX_primary_ke y to fetch max of primary key from table name where table id is 1
DECLARE @MAX_primary_ke y @Primarykey_DAT ATYPE
SELECT @MAX_primary_ke y = MAX(@primary_ke y) FROM @TABLE_NAME
WHERE TABLE_ID = @COUNTER
---But by running it i am getting error that "Incorrect syntax near '@Primarykey_DA TATYPE'. and "Must declare the variable '@MAX_primary_k ey'.
Please suggest
Thanks in Advance
1 1417
HI Experts,
I have same table structures in two database and one master table which contains Table id, Table name,primary key, data type of primary key. i have to comapare
Tables in both tha database and as per result i have to do insert,update or delete.
for that i have written query :
DECLARE @rowcount_maste rtable FLOAT
SET @rowcount_maste rtable = (select count(*) from master_table)
DECLARE @TABLE_ID float,
@TABLE_NAME varchar (100),
@primary_key varchar (100),
@Primarykey_DAT ATYPE varchar (50),
DECLARE @COUNTER FLOAT
SET @COUNTER = 1
WHILE (@Counter <= @rowcount_maste rtable)
Begin
SET @TABLE_NAME = (SELECT TABLE_NAME FROM MASTER_TABLE TABLE_ID = @COUNTER)
SET @primary_key = (SELECT primary_key FROM MASTER_TABLE WHERE TABLE_ID = @COUNTER)
SET @Primarykey_DAT ATYPE = (SELECT Primarykey_DATA TYPE FROM MASTER_TABL WHERE TABLE_ID = @COUNTER)
--In below line i want to declare a variable and datatype should be same as what we got from master table so that i can use this @MAX_primary_ke y to fetch max of primary key from table name where table id is 1 DECLARE @MAX_primary_ke y @Primarykey_DAT ATYPE
SELECT @MAX_primary_ke y = MAX(@primary_ke y) FROM @TABLE_NAME
WHERE TABLE_ID = @COUNTER
---But by running it i am getting error that "Incorrect syntax near '@Primarykey_DA TATYPE'. and "Must declare the variable '@MAX_primary_k ey'.
Please suggest
Thanks in Advance
Examine this line more closely...
DECLARE @MAX_primary_ke y @Primarykey_DAT ATYPE
at what point are you declaring either of these variable datatypes?
Jim :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have the properties:
mode1, mode2, and mode3.
This seems simple but I can't quite figure it out...
Any ideas anyone?
|
by: Steve Jorgensen |
last post by:
Many of the regulars here have explained that declaring variables using As New
.... is a bad idea, and some have given some good explanations, but I wanted
add one more demonstration to the mix. This example is less practical than
some, but more illustrative than most. I came up with this to show a fellow
programmer why I think he's using As New ... too much, and I though I might as
well share it here, too.
First create a class as...
|
by: ALI-R |
last post by:
Hi All,
First of all I think this is gonna be one of those threads :-) since I have
bunch of questions which make this very controversial:-0)
Ok,Let's see:
I was reading an article that When you pass a Value-Type to method call
,Boxing and Unboxing would happen,Consider the following snippet:
int a=1355;
myMethod(a);
......
|
by: matty |
last post by:
Hi,
I recently got very confused (well that's my life) about the
"undefined" value. I looked in the FAQ and didn't see anything about
it. On http://www.webreference.com/programming/javascript/gr/column9/
they say:
<snip>
The undefined property
A relatively recent addition to JavaScript is the undefined property.
|
by: MLH |
last post by:
120 MyString = "How many copies of each letter do you need?"
150 MyVariant = InputBox(MyString, "How Many?", "3")
If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'"
If MyVariant = 2 Then MsgBox "MyVariant also equals the value 2"
160 If MyVariant = "" Then HowManyCopies = 1
170 If Not IsNumeric(MyVariant) Then HowManyCopies = 1
MsgBox "OK. HowManyCopies has a value of " & CStr(HowManyCopies)
180 For i =...
| |
by: Jess |
last post by:
Hello,
I tried several books to find out the details of object
initialization. Unfortunately, I'm still confused by two specific
concepts, namely default-initialization and value-initialization. I
think default-init calls default constructor for class objects and
sets garbage values to PODs. Value-init also calls default
constructor for class objects and sets 0s to POD types. This is what
I've learned from the books (especially...
|
by: minkoo.seo |
last post by:
Hi.
I've got a question on the differences and how to define static and
class variables. AFAIK, class methods are the ones which receives the
class itself as an argument, while static methods are the one which
runs statically with the defining class.
Hence, my understanding is that static variables must be bound to the
class defining the variables and shared by children of parent class
where the variable is defined. But, please have a...
|
by: polas |
last post by:
Afternoon all,
I have some code (which I thought was OK, but now appreciate is
probably not by the standard) which contains
int a;
......
if (a==NULL)
{
....
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |