Click here to Skip to main content
15,886,137 members
Home / Discussions / Database
   

Database

 
QuestionValidating data between RDBMS (Mysql/ Oracle / DB2) and Hadoop ( HDFS/ Hive) Pin
Member 1204409721-Oct-15 4:14
Member 1204409721-Oct-15 4:14 
AnswerRe: Validating data between RDBMS (Mysql/ Oracle / DB2) and Hadoop ( HDFS/ Hive) Pin
Richard Deeming21-Oct-15 8:12
mveRichard Deeming21-Oct-15 8:12 
QuestionSchema update using SQL Server Data Tools Pin
indian14319-Oct-15 12:15
indian14319-Oct-15 12:15 
AnswerRe: Schema update using SQL Server Data Tools Pin
Mycroft Holmes19-Oct-15 14:35
professionalMycroft Holmes19-Oct-15 14:35 
GeneralRe: Schema update using SQL Server Data Tools Pin
indian14319-Oct-15 15:54
indian14319-Oct-15 15:54 
QuestionReferencing DacPac file from different Server and Database Pin
indian14319-Oct-15 10:34
indian14319-Oct-15 10:34 
AnswerRe: Referencing DacPac file from different Server and Database Pin
Mycroft Holmes19-Oct-15 14:30
professionalMycroft Holmes19-Oct-15 14:30 
QuestionLimiting the scope of a Table variable Pin
indian14317-Oct-15 6:35
indian14317-Oct-15 6:35 
Hi All,

I few SQL scripts and in them I am using Table variables to store values from select queries then loop through that table variable to avoid duplicate entries in the tables.

Like
Declare @TabA  Table(Id identity, Name varchar, Description varchar)
Insert into @TabA SELECT Name, Description FROM XXXX

Loop through Table Variable using Id and check if that Name already doesn't exist in the TabB then insert else don't.

Now I have interesting question, I am using many inserts in different blocks within same sql script. When I try to declare same Table Variable name again @TabA, it says, it already exists. I don't want to use Drop statement in my script,
1. is there any way that I can make the table variable drop automatically within same script, otherwise do I need to declare different table variable for each insert, if that's the case then wouldn't it be more stress on the RAM as many table variables would exist in the RAM until that whole script runs?
2. I am afraid to use delete on the same Table variable to use it in next insert, For example, if I have to insert into TablC table which has same set of Columns Name and Description, how does Delete works on the table variable would it create Ids from where it left in the before insert or would it create Ids from 1st again?
3 And another question is, if we are running multiple sql files at the same time, do we need to use different table variable names in all of those sql files or the scope of the Table Variable dies soon after each sql file runs?

Please answer these questions any suggestions, links and even code snippets would help me a lot, thanks in advance.
Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."

AnswerRe: Limiting the scope of a Table variable Pin
Mycroft Holmes17-Oct-15 13:40
professionalMycroft Holmes17-Oct-15 13:40 
GeneralRe: Limiting the scope of a Table variable Pin
indian14319-Oct-15 10:28
indian14319-Oct-15 10:28 
QuestionMove GROUP_CONCAT's comma values to columns Pin
Jassim Rahma15-Oct-15 6:45
Jassim Rahma15-Oct-15 6:45 
AnswerRe: Move GROUP_CONCAT's comma values to columns Pin
Jassim Rahma15-Oct-15 8:02
Jassim Rahma15-Oct-15 8:02 
GeneralRe: Move GROUP_CONCAT's comma values to columns Pin
Jassim Rahma24-Oct-15 1:28
Jassim Rahma24-Oct-15 1:28 
QuestionFilling many to many rel table using Select statement Pin
indian14314-Oct-15 7:18
indian14314-Oct-15 7:18 
AnswerRe: Filling many to many rel table using Select statement Pin
Mycroft Holmes14-Oct-15 12:50
professionalMycroft Holmes14-Oct-15 12:50 
GeneralRe: Filling many to many rel table using Select statement Pin
KDGOLE14-Oct-15 21:27
KDGOLE14-Oct-15 21:27 
GeneralRe: Filling many to many rel table using Select statement Pin
indian14317-Oct-15 6:17
indian14317-Oct-15 6:17 
GeneralRe: Filling many to many rel table using Select statement Pin
indian14319-Oct-15 10:30
indian14319-Oct-15 10:30 
QuestionGet check time from separate fields in Microsoft SQL Server Pin
Jassim Rahma14-Oct-15 0:11
Jassim Rahma14-Oct-15 0:11 
AnswerRe: Get check time from separate fields in Microsoft SQL Server Pin
Mycroft Holmes14-Oct-15 1:11
professionalMycroft Holmes14-Oct-15 1:11 
GeneralRe: Get check time from separate fields in Microsoft SQL Server Pin
Chris Quinn14-Oct-15 2:30
Chris Quinn14-Oct-15 2:30 
GeneralRe: Get check time from separate fields in Microsoft SQL Server Pin
Richard Deeming14-Oct-15 2:47
mveRichard Deeming14-Oct-15 2:47 
GeneralRe: Get check time from separate fields in Microsoft SQL Server Pin
Chris Quinn14-Oct-15 2:50
Chris Quinn14-Oct-15 2:50 
QuestionInsert within Select Statement Pin
indian14313-Oct-15 7:50
indian14313-Oct-15 7:50 
AnswerRe: Insert within Select Statement Pin
Richard Deeming13-Oct-15 8:43
mveRichard Deeming13-Oct-15 8:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.