avi-631555 (9/14/2010)
Basically i am trying to accomplishInserting data into a table only if it doesnot exist and if does to show me the content of the table and print a simple message in either case, but i can seem to accomplish this
If exists
(Select * from TableA where PKEY = '1' )
---Display the content of the table
Select * FROM TableA
Print 'Table A info'
Else
Insert Into TableA
(X,Y,Z)
Values(1,'testLink', TestValue)
Print 'Table has been inserted with the specified data'
GO
tHanks for the help
I guess all that's missing are the BEGIN..END statements to define the IF..ELSE blocks:
If exists
(Select * from TableA where PKEY = '1' )
BEGIN
---Display the content of the table
Select * FROM TableA
Print 'Table A info'
END
Else
BEGIN
Insert Into TableA
(X,Y,Z)
Values(1,'testLink', TestValue)
Print 'Table has been inserted with the specified data'
END