Transact SQL :: How To Create Candidate And Super Key

Jun 1, 2015

I did lot of google but did not get script for candidate and super key. I do not have syntax to create candidate and super key in sql.

View 4 Replies


ADVERTISEMENT

Super Key && Candidate Key....

Feb 26, 2008

 
can anyone explain what are superkeys & candidate keys with a simple example?
Thanx...

View 2 Replies View Related

Help Me Id Candidate And Superkeys Please

Mar 17, 2006

The relation (table) schema is multimedia (mm_id, f_name, extension, directory, size).

1) Identify at least three super keys for the relation called ?multimedia?.
2) Identify at least two candidate keys for the relation called ?multimedia?

Thanks much

View 14 Replies View Related

Candidate For Partitioning?

Feb 12, 2008



I have a table that looks like this:

ItemID TokenID WordCount
12345 11334 5
12345 3453 1
12345 546546 2
12345 242555 1
12345 556346 4
12345 346346 1






Code SnippetCREATE TABLE [dbo].[ItemTokensLink](
[ItemID] [int] NOT NULL,
[TokenID] [int] NOT NULL,
[WordCount] [int] NOT NULL DEFAULT ((1)),
CONSTRAINT [PK_ItemTokensLink_1] PRIMARY KEY CLUSTERED
(
[ItemID] ASC,
[TokenID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]






So this table has now reached over 22 million rows. The problem is my machine only has 1GB ram....so SQl Server tries to load up the whole table and this is ~560MB....equals zero ram for ...well anything else!

Does SQL Server load up an entire table when performing an INSERT?




Code Snippet


INSERT INTO ItemTokensLink(ItemID, TokenID, WordCount)
SELECT DISTINCT @ItemID as ItemID, t.TokenID, Count(t.TokenID) as WordCount
FROM #Tokens t
Group by TokenID




@ItemID is parameter provided
#Tokens is a temp table create with a word list


Would partitioning help here?

The table is is 80% of the time added to and the ItemID will always increase. What is the best to deal with massive tables that are inserted to frequently?

How does SQL Server decide when to load a table into memory?
TIA

View 5 Replies View Related

Candidate,composite And Alternate Key

Jun 6, 2008

 Hi What is the difference between Candidate key , composite key and alternate key. I went through many websites but I didn't get examples. There were only definitions. Can anyone please tell me the site or blogs that elaborate this concept RegardsKaran 

View 2 Replies View Related

SQL Server 2008 Release Candidate (Express)Beta

Jun 17, 2008

I downloaded SQL Server 2008 Release Candidate (Express) Beta on 6/16/08. Installation started but failed. A message stated Microsoft NET Framework 2.0 SP2 needs to be installed first.

I downloaded SP2 and installed it. However, when I try again to install the SQL 2008 Release Candidate Beta I get the same message that SP2 must first be installed.

Can someone tell me how to make the SQL Beta version installer recognize the previously installed SP2 Service Pack?

Thanks, Norman

View 1 Replies View Related

Super Basic Help

Nov 5, 2007

I'm use to working with MSaccess and coldfusion and am trying to convert to sql. I ran the upsize wizard in access and now see my DB in the SQL Query Analyzer. How do I open / modify / view the DB? I have zero experience with sql so treat me like a 5 year old.

And if anyone has any knowledge of connecting coldfusion with sql that would also help.

Thanks.

View 9 Replies View Related

Super Beginner Question

Apr 9, 2003

Begging your patience, I'm wondering if someone can help me with a beginner question. I am trying to write a query against our trouble ticket DB. I want to find tickets that have multiple tech assignments associated with a single ticket. How can write a query that says if in the CALLID field you find the same value more than once, return those rows and only those rows?

Thanks very much.

View 4 Replies View Related

Sql View Very Very Slow The First Run And Then Super Fast... Why?

Nov 2, 2007

Hi,
I have a query that takes 15minutes to run the first time after sql server start but then for subsequent querys is superfast (less than 10 secs).
Why? What could I do to speed up the first run?
Here is the source:



Code Block
SELECT Articoli.Articolo, Articoli.BarCodeVen, Articoli.Descri, Articoli.Merce, Articoli.CodIVA, Articoli.UMBase, Articoli.PrzBase, Articoli.Sconto1, Articoli.Sconto2,
Articoli.ScontoFormula, Articoli.Ricarico, Articoli.TipoArt, Articoli.CatMerc, Articoli.CatOmo, Articoli.CatProvv, Articoli.CntrprtVen, Articoli.CntrprtAcq,
Articoli.Dispniblta, Articoli.Vendita, Articoli.SiCli, Articoli.SiFor, Articoli.NotaPriv, Articoli.NotaPubb, Articoli.Immagine, Articoli.Produttore, Articoli.SiMatr,
Articoli.OldCodArt, Articoli.Disattivo, Articoli.CatProd, Articoli.SotCatProd, Articoli.EsplKit, Articoli.ScaricoCom, Articoli.ImmagLun, Articoli.DataModCS,
Articoli.ValorizPr, Articoli.Natura, Articoli.UMSecScelta, Articoli.SecScelta, Articoli.Acquisto, Articoli.CntConsumi, Articoli.NonMovimentabile,
Articoli.ProvAgente, Articoli.Taglia, Articoli.Colore, Articoli.CodArtNeutro, Articoli.Collezione, Articoli.Assortimento, Articoli.Centro,
Articoli.InibisciRicercaUnMis, Articoli.Commessa, Articoli.DescriTesto, Articoli.Disattivabile, Articoli.KwTipoArt, Articoli.KwTipoArtNeutro,
Articoli.KwNeutro, Articoli.KwCollezione, Articoli.KwLinea, Articoli.KwModello, Articoli.KwMateriale, Articoli.KwComposizione, Articoli.KwPosRiga,
Articoli.KwVarRiga, Articoli.KwPosColonna, Articoli.KwVarColonna, Articoli.KwPos3D, Articoli.KwVar3D, Articoli.KwGrpVarRiga, Articoli.KwGrpVarColonna,
Articoli.KwGrpVar3D, Articoli.KwEtiMan, Articoli.KwAssortimento, Articoli.KwGrpFormule, Articoli.KwSpecimen, KwVarArticolo.TipoVariante,
KwVarArticolo.Variante, KwVarArticolo.Posizione, KwVarArticolo.Categoria, KwVarArticolo.DescriVariante,
KwVarArticolo.P07009Descrizione1 AS Descrizione1, KwVarArticolo.P07009Descrizione2 AS Descrizione2, CatOmo.Descri AS CatOmoDescri,
KwModelli.Descri AS DescriModello, KwMateriali.Descri AS DescriMateriale, MFDBCompon_Tomaia2.DatoTecnico,
MFDBCompon_Tomaia2.DBPosColonna, MFDBCompon_Tomaia2.DBPos3D, MFDBCompon_Tomaia2.CompNeutro,
MFDBCompon_Tomaia2.CompVarRiga, Articoli_1.Descri AS DescriCompNeutro, MFKwVariantiRiga.DescriVariante AS DescriRigaCompo,
CatProvv.Descri AS CatProvvDescri, MFDBCompon_Tomaia3.CompNeutro AS CompNeutroT3,
MFDBCompon_Tomaia3.CompVarRiga AS CompVarrigaT3, Articoli_2.Descri AS DescriCompNeutroT3,
MFKwVariantiRiga_1.DescriVariante AS DescriRigaCompoT3, MFDBCompon_Acc1.CompNeutro AS CompNeutroAcc1,
MFDBCompon_Acc1.CompVarRiga AS CompVarRigaAcc1, Articoli_3.Descri AS DescriCompNeutroAcc1,
MFKwVariantiRiga_2.DescriVariante AS DescriRigaCompoAcc1, MFDBCompon_Acc2.CompNeutro AS CompNeutroAcc2,
MFDBCompon_Acc2.CompVarRiga AS CompVarRigaAcc2, Articoli_4.Descri AS DescriCompNeutroAcc2,
MFKwVariantiRiga_3.DescriVariante AS DescriRigaCompoAcc2, MFDBCompon_SottoP_Tallonet.CompNeutro AS CompNeutroSottop,
MFDBCompon_SottoP_Tallonet.CompVarRiga AS CompVarRigaSottop, MFDBCompon_SottoP_Tallonet.DescriCompNeutroSottop,
MFDBCompon_SottoP_Tallonet.DescriRigaCompoSottop, MFDBCompon_SottoP_Tallonet.DatoTecnico AS DatoTecnicoSottop,
MFDBCompon_RicSol.CompNeutro AS CompNeutroRicSol, MFDBCompon_RicSol.CompVarRiga AS CompVarRigaRicSol,
MFDBCompon_RicSol.DescriCompNeutroRicSol, MFDBCompon_RicSol.DescriRigaCompoRicSol,
MFDBCompon_Fodera.CompNeutro AS CompNeutroFodera, MFDBCompon_Fodera.CompVarRiga AS CompVarRigaFodera,
MFDBCompon_Fodera.DescriCompNeutroFodera, MFDBCompon_Fodera.DescriRigaCompoFodera, MFDBCompon_Forma.Descri AS DescriForma,
MFDBCompon_Tacco.Descri AS DescriTacco, MFVar3D_Pos1.DescriVariante AS Descri_Pos1, MFVar3D_Pos2.DescriVariante AS Descri_Pos2,
MFVar3D_Pos3.DescriVariante AS Descri_Pos3, MFVar3D_Pos4.DescriVariante AS Descri_Pos4, MFListinoP00New.Prz AS P00,
MFListinoP00New.InVigoreDa AS DataP00, MFListinoP05New.Prz AS P05, MFListinoP05New.InVigoreDa AS DataP05, MFListinoPUSANew.Prz AS PUSA,
MFListinoPUSANew.InVigoreDa AS DataPUSA,
CASE WHEN KwVarArticolo.P07009Descrizione2 <> '' THEN KwVarArticolo.P07009Descrizione2 ELSE CASE WHEN Articoli.CatProvv = '30SPORT' THEN Articoli.KwNeutro
+ KwVarArticolo.Variante + '.jpg' ELSE Articoli.KwNeutro + '.jpg' END END AS MFFoto, MFListinoRUSANew.Prz AS RUSA,
MFListinoRUSANew.InVigoreDa AS DataRUSA, MFListinoRITANew.Prz AS RITA, MFListinoRITANew.InVigoreDa AS DataRITA, ArtMerce.Fornitore
FROM Articoli INNER JOIN
KwVarArticolo ON Articoli.Articolo = KwVarArticolo.Articolo INNER JOIN
CatOmo ON Articoli.CatOmo = CatOmo.Categoria INNER JOIN
KwMateriali ON Articoli.KwModello = KwMateriali.KwModello AND Articoli.KwMateriale = KwMateriali.KwMateriale INNER JOIN
KwModelli ON Articoli.KwModello = KwModelli.KwModello AND Articoli.KwMateriale = KwModelli.KwMateriale LEFT OUTER JOIN
ArtMerce ON Articoli.Articolo = ArtMerce.Articolo LEFT OUTER JOIN
MFListinoRUSANew ON KwVarArticolo.Variante = MFListinoRUSANew.VarRiga AND Articoli.KwNeutro = MFListinoRUSANew.Neutro LEFT OUTER JOIN
MFListinoRITANew ON KwVarArticolo.Variante = MFListinoRITANew.VarRiga AND Articoli.KwNeutro = MFListinoRITANew.Neutro LEFT OUTER JOIN
MFListinoPUSANew ON KwVarArticolo.Variante = MFListinoPUSANew.VarRiga AND Articoli.KwNeutro = MFListinoPUSANew.Neutro LEFT OUTER JOIN
MFListinoP05New ON KwVarArticolo.Variante = MFListinoP05New.VarRiga AND Articoli.KwNeutro = MFListinoP05New.Neutro LEFT OUTER JOIN
MFListinoP00New ON Articoli.KwNeutro = MFListinoP00New.Neutro AND KwVarArticolo.Variante = MFListinoP00New.VarRiga LEFT OUTER JOIN
MFVar3D_Pos4 ON Articoli.KwNeutro = MFVar3D_Pos4.Articolo LEFT OUTER JOIN
MFVar3D_Pos3 ON Articoli.KwNeutro = MFVar3D_Pos3.Articolo LEFT OUTER JOIN
MFVar3D_Pos2 ON Articoli.KwNeutro = MFVar3D_Pos2.Articolo LEFT OUTER JOIN
MFVar3D_Pos1 ON Articoli.KwNeutro = MFVar3D_Pos1.Articolo LEFT OUTER JOIN
MFDBCompon_Forma ON KwVarArticolo.Variante = MFDBCompon_Forma.DBVarRiga AND
Articoli.Articolo = MFDBCompon_Forma.DBNeutro LEFT OUTER JOIN
MFDBCompon_Tacco ON KwVarArticolo.Variante = MFDBCompon_Tacco.DBVarRiga AND
Articoli.Articolo = MFDBCompon_Tacco.DBNeutro LEFT OUTER JOIN
MFDBCompon_Fodera ON KwVarArticolo.Variante = MFDBCompon_Fodera.DBVarRiga AND
Articoli.KwNeutro = MFDBCompon_Fodera.DBNeutro LEFT OUTER JOIN
MFDBCompon_RicSol ON KwVarArticolo.Variante = MFDBCompon_RicSol.DBVarRiga AND
Articoli.KwNeutro = MFDBCompon_RicSol.DBNeutro LEFT OUTER JOIN
MFDBCompon_SottoP_Tallonet ON KwVarArticolo.Variante = MFDBCompon_SottoP_Tallonet.DBVarRiga AND
Articoli.KwNeutro = MFDBCompon_SottoP_Tallonet.DBNeutro LEFT OUTER JOIN
MFDBCompon_Acc2 INNER JOIN
Articoli AS Articoli_4 ON MFDBCompon_Acc2.CompNeutro = Articoli_4.Articolo INNER JOIN
MFKwVariantiRiga AS MFKwVariantiRiga_3 ON MFDBCompon_Acc2.CompVarRiga = MFKwVariantiRiga_3.Variante ON
KwVarArticolo.Variante = MFDBCompon_Acc2.DBVarRiga AND Articoli.KwNeutro = MFDBCompon_Acc2.DBNeutro LEFT OUTER JOIN
MFDBCompon_Acc1 INNER JOIN
Articoli AS Articoli_3 ON MFDBCompon_Acc1.CompNeutro = Articoli_3.Articolo INNER JOIN
MFKwVariantiRiga AS MFKwVariantiRiga_2 ON MFDBCompon_Acc1.CompVarRiga = MFKwVariantiRiga_2.Variante ON
KwVarArticolo.Variante = MFDBCompon_Acc1.DBVarRiga AND Articoli.KwNeutro = MFDBCompon_Acc1.DBNeutro LEFT OUTER JOIN
MFDBCompon_Tomaia3 INNER JOIN
Articoli AS Articoli_2 ON MFDBCompon_Tomaia3.CompNeutro = Articoli_2.Articolo INNER JOIN
MFKwVariantiRiga AS MFKwVariantiRiga_1 ON MFDBCompon_Tomaia3.CompVarRiga = MFKwVariantiRiga_1.Variante ON
KwVarArticolo.Variante = MFDBCompon_Tomaia3.DBVarRiga AND Articoli.KwNeutro = MFDBCompon_Tomaia3.DBNeutro LEFT OUTER JOIN
CatProvv ON Articoli.CatProvv = CatProvv.Categoria LEFT OUTER JOIN
Articoli AS Articoli_1 INNER JOIN
MFDBCompon_Tomaia2 ON Articoli_1.Articolo = MFDBCompon_Tomaia2.CompNeutro INNER JOIN
MFKwVariantiRiga ON MFDBCompon_Tomaia2.CompVarRiga = MFKwVariantiRiga.Variante ON
KwVarArticolo.Variante = MFDBCompon_Tomaia2.DBVarRiga AND Articoli.KwNeutro = MFDBCompon_Tomaia2.DBNeutro
WHERE (Articoli.KwCollezione = @KwCollezione) AND (Articoli.KwLinea = @KwLinea) AND (KwVarArticolo.TipoVariante = 52559872) AND
(Articoli.CatProvv IN (@CatProvv)) AND (Articoli.Disattivo = '0') AND (KwVarArticolo.Disattivo = '0') AND (ArtMerce.Fornitore IN (@Fornitore)) OR
(Articoli.KwCollezione = @KwCollezione) AND (Articoli.KwLinea = @KwLinea) AND (KwVarArticolo.TipoVariante = 52559872) AND
(Articoli.CatProvv IN (@CatProvv)) AND (Articoli.Disattivo = '0') AND (KwVarArticolo.Disattivo = '0') AND ('ALL' IN (@Fornitore)) OR
(Articoli.KwCollezione = @KwCollezione) AND (Articoli.KwLinea = @KwLinea) AND (KwVarArticolo.TipoVariante = 52559872) AND (Articoli.Disattivo = '0')
AND (KwVarArticolo.Disattivo = '0') AND (ArtMerce.Fornitore IN (@Fornitore)) AND ('ALL' IN (@CatProvv)) OR
(Articoli.KwCollezione = @KwCollezione) AND (Articoli.KwLinea = @KwLinea) AND (KwVarArticolo.TipoVariante = 52559872) AND (Articoli.Disattivo = '0')
AND (KwVarArticolo.Disattivo = '0') AND ('ALL' IN (@CatProvv)) AND ('ALL' IN (@Fornitore))
ORDER BY Articoli.CatProvv, Articoli.CatOmo, Articoli.Articolo, KwVarArticolo.Posizione


Thank you!
Roberto

View 3 Replies View Related

Super Dumb Question (Archiving)

Dec 12, 2007

Hi,

This is probably a no-brainer for most of you, but I'm really really new to sql.

I'm using ms sql 2005 (I think), and I'm making a scheduling program in VB that uses a database hosted on the sql server. Does sql come with archiving tools, or will I need to make something? All the other DBs on the server are 3rd party apps that have a little archiving tool as part of the utilities package. Will I have to make something like that to remove and save the old schedule entries? If so, can anyone point me in the right direction?

Thanks,
Chris

View 9 Replies View Related

Super Green Newbie Dba - Tran Log Problem... Help, Please?

Oct 9, 2004

Well, I can't backup up my tran log - too big. I knew enough to know you have to back it up, didn't know enough to know that tran log backup is not included in "Full backup". Contractor installation set Growth to "un-restricted". Me, too swamped to delve deeply in time to learn this is a recipe for disaster, and then it was too late - System down because tran log filled up the disk...

(Ironically, this happened the morning of the first day of some training they sent me to - Microsoft's Programming a Microsoft SQL 2000 Database...)

So, some details... The drives on the system :
___ c: size 12G, free 7G
___ d: size 44.9G, free 10M
___ e: size 44.9G, free 13G

Tran log info :
___ filename .... d:Microsoft SQL ServerMSSQLdatahorizon_Log.LDF
___ name ........ horizon_Log
___ size ........ 5606392
___ maxsize ..... -1
___ growth ...... 10
___ status ...... 1081410

___ filename ...E:Horizon_Log2Horizon_Log2_Temp
___ name ........ horizon_1_Log
___ size ........ 167168
___ maxsize ..... 640000
___ growth ...... 640
___ status ...... 32834

(there are 2 because the other totally green newbie dba added 1 the day the system went down...)


I *thought* the addition of the 2nd tran log file meant the 1st file was no longer part of the picture, and that my available free disk space was sufficient to backup the 2nd tran log file.

Clearly I'm missing something - when I try to back up, I get this in SQL server error log :
___ Operating system error 112(There is not enough space on the disk.)


:confused:___ Does that mean it's trying to backup both the 1st & the 2nd tran logs?
:confused:___ Or is it only backing up the 2nd log, but trying to use D: (with only 10M)?
:confused:___ Or, is it using C: or E:, but tran log backups need some multiple of the size of the actual log, and there's not enough space even though there are multiple G?


I've been reading & googling. So far tried to truncate both files.
( dbcc shrinkfile('horizon_1_log',truncateonly) )
No luck, got these :
___ Cannot shrink log file 2 (horizon_Log) because all logical log files are in use.
___ Cannot shrink log file 3 (horizon_1_Log) because all logical log files are in use.

:confused:
:confused:___ How do I get them to be not "in use"?
:confused:___ Must the system be down for that? (certainly seems to...)


Also, checked out the EMPTYFILE option. Books Online says :
"Migrates all data from the specified file to other files in the same filegroup"

:confused: ___ Migrates to which "other files", exactly?
:confused: ___ Is this the right way to go?
:confused: ___ If so, how would I proceed after achieving a successul EMPTYFILE operation?


Also...
:confused: ___ In the database's Properties dialog, Transaction Log tab, there's a Delete button. Could that button be used to get me out of this difficulty?


Last, but not least... If I'm going about this altogether wrongly, can I get a pointer or two?

TIA for any and all feedback...

View 10 Replies View Related

Update Stored Proc Super Slow

Nov 5, 2006

we just moved a database from a shared SQL 2000 server to SQLExpress on a VPS server. Every thing seems to work great, really no performance loss at all, except for one stored proc that is giving us problems. It's function is to update a history table, and then update the production table. On the old server, it would take less than a second to run this, now it takes anywhere from 45 seconds to 1 minute or it times out. This database is used on a classic asp web app. ANY help at all on this would be appreciated as I am pulling my hair out trying to figure out what's wrong here. here is the proc.

------------------------------------------ code ----------------------------------------------
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
SET NOCOUNT ON
go





ALTER PROCEDURE [dbo].[sp_UpdatePersonalization]
@p_id nvarchar(50),
@cust_num varchar(50),
--@publication varchar(25),
@full_name varchar(500),
@email varchar(200),
@web_address varchar(300),
@include_web bit,
@ReturnAddressYN varchar(1),
@include_email bit,
@job_title varchar(500),
@company_name varchar(500),
@tagline varchar(1000),
@phone1 varchar(30),
@phone2 varchar(30),
@phone3 varchar(30),
@phone4 varchar(30),
@phoneext1 varchar(10),
@phoneext2 varchar(10),
@phoneext3 varchar(10),
@phoneext4 varchar(10),
@phonedesc1 varchar(20),
@phonedesc2 varchar(20),
@phonedesc3 varchar(20),
@phonedesc4 varchar(20),
@company_mail_address varchar(500),
@masthead varchar(250),
@verbiage_page1 varchar(1400),
@verbiage_page4 varchar(2650),
@inc_bbb bit,
@inc_ehl bit,
@inc_eho bit,
@inc_rl bit,
@p_comments varchar(500),
@p_update_flag varchar(10)
--@frequency varchar(50),
--@mail varchar(50),
--@fold varchar(50),
--@contact varchar(50),
-- do not add this on the update! @date_added,



AS
declare @last_updated datetime
select @last_updated=GETDATE()
declare @set_update bit
--if @p_update_flag='False'
--select @set_update = 1
--else
--select @set_update = 0

if @p_update_flag='False'
INSERT INTO pers_main_arch
(
p_id,
cust_num,
publication,
full_name,
email,
web_address,
include_web,
include_email,
job_title,
company_name,
tagline,
phone1,
phone2,
phone3,
phone4,
phoneext1,
phoneext2,
phoneext3,
phoneext4,
phonedesc1,
phonedesc2,
phonedesc3,
phonedesc4,
company_mail_address,
masthead,
verbiage_page1,
verbiage_page4,
inc_bbb,
inc_ehl,
inc_eho,
inc_rl,
p_comments,
frequency,
mail,
fold,
contact,
date_added,
last_updated,
start_month,
ReturnAddressYN
)
SELECT
pm.p_id,
pm.cust_num,
pm.publication,
pm.full_name,
pm.email,
pm.web_address,
pm.include_web,
pm.include_email,
pm.job_title,
pm.company_name,
pm.tagline,
pm.phone1,
pm.phone2,
pm.phone3,
pm.phone4,
pm.phoneext1,
pm.phoneext2,
pm.phoneext3,
pm.phoneext4,
pm.phonedesc1,
pm.phonedesc2,
pm.phonedesc3,
pm.phonedesc4,
pm.company_mail_address,
pm.masthead,
pm.verbiage_page1,
pm.verbiage_page4,
pm.inc_bbb,
pm.inc_ehl,
pm.inc_eho,
pm.inc_rl,
pm.p_comments,
pm.frequency,
pm.mail,
pm.fold,
pm.contact,
pm.date_added,
pm.last_updated,
pm.start_month,
pm.ReturnAddressYN
FROM pers_main pm
WHERE pm.cust_num = @cust_num

if @p_update_flag='True' OR @p_update_flag='False' OR @p_update_flag IS NULL OR @p_update_flag=''
UPDATE pers_main SET
--cust_num=@cust_num,
--publication=@publication,
full_name=@full_name,
email=@email,
web_address=@web_address,
include_web=@include_web,
include_email=@include_email,
job_title=@job_title,
company_name=@company_name,
tagline=@tagline,
phone1=@phone1,
phone2=@phone2,
phone3=@phone3,
phone4=@phone4,
phoneext1=@phoneext1,
phoneext2=@phoneext2,
phoneext3=@phoneext3,
phoneext4=@phoneext4,
phonedesc1=@phonedesc1,
phonedesc2=@phonedesc2,
phonedesc3=@phonedesc3,
phonedesc4=@phonedesc4,
company_mail_address=@company_mail_address,
masthead=@masthead,
verbiage_page1=@verbiage_page1,
verbiage_page4=@verbiage_page4,
inc_bbb=@inc_bbb,
inc_ehl=@inc_ehl,
inc_eho=@inc_eho,
inc_rl=@inc_rl,
p_comments=@p_comments,
--frequency=@frequency,
--mail=@mail,
--fold=@fold,
--contact=@contact,
--date_added,
last_updated=@last_updated,
updated_flag=1,
ReturnAddressYN=@ReturnAddressYN
WHERE cust_num=@cust_num
------------------------------------------ code ----------------------------------------------

View 1 Replies View Related

CREATE ENDPOINT (Transact-SQL)

Jun 3, 2007

hello all i am new here,



my question is how i can activate http in sql server 2005

i want to run a helpdesk application but i cant make a new database.

it has something to do with create endpoint, i have no knowlege off sql server 2005 its not my field



can someone help me please?

View 3 Replies View Related

Transact SQL :: How To Create One To Many Relationship

Jul 29, 2015

I have got a table as follow:

CREATE TABLE [dbo].[NozzleAllTbl] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[nBDId] INT NULL,
[nShellId] INT NULL,
[nTDId] INT NULL,
CONSTRAINT [PK_dbo.NozzleAllTbl] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_dbo.NozzleAllTbl_dbo.NozzleTbl_nBDId] FOREIGN KEY ([nBDId]) REFERENCES [dbo].[NozzleTbl] ([Id]),
CONSTRAINT [FK_dbo.NozzleAllTbl_dbo.NozzleTbl_nShellId] FOREIGN KEY ([nShellId]) REFERENCES [dbo].[NozzleTbl] ([Id]),
CONSTRAINT [FK_dbo.NozzleAllTbl_dbo.NozzleTbl_nTDId] FOREIGN KEY ([nTDId]) REFERENCES [dbo].[NozzleTbl] ([Id])
);

NozzleTbl is another Table.At the moment I am referencing only one NozzleTbl thrice. But how can I reference a collection of NozzleTbl thrice?So that in the c# code I could access the collections as:

NozzleTbl_1 = NozzleAllTbl.NozzleTbls[0]
NozzleTbl_2 = NozzleAllTbl.NozzleTbls[1]
...
NozzleTbl1_1 = NozzleAllTbl.NozzleTbls1[0]
NozzleTbl2_1 = NozzleAllTbl.NozzleTbls2[0]
....

View 2 Replies View Related

Using Transact SQL To Create And Add An SSIS Package

Aug 22, 2007

Can someone point me to any whitepaper on how to use a Transact SQL script to create an SSIS package. I will need to be able to run the script at various customer sites.

View 11 Replies View Related

Transact SQL :: How To Create Column (Region)

Oct 19, 2015

create the column "Region" like this Picture?.

View 26 Replies View Related

Transact SQL :: Using A Parameter To Create A Table?

Jul 21, 2015

I create a script like below:

GO
SET ANSI_PADDING ON
GO
DECLARE
@ProjectID  AS NVARCHAR(128),
@TableName  AS NVARCHAR(128);
SET @ProjectID = N'EPA';

[code]....

The table created, but T-SQL created a table called @TableName.not like "EPA_SweetChargeCodeAssignees'

how to debug?

View 2 Replies View Related

Transact SQL :: Create Table Script

Jul 21, 2015

When I right click on a table and click Script Table as --> Create to -->  it scripts out:

CREATE TABLE [dbo].[Test](            
[FirstName] [varchar](50) NULL,            
[LastName] [varchar](50) NULL,            
[Address] [varchar](50()  NULL
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[Test] ADD [City] [varchar](50) NULL
 
Why is there an Alter table statement?  I’m assuming this table was altered at some point but why is SQL not just doing a create table and how is it keeping track of these changes?

View 4 Replies View Related

Transact SQL :: Dynamically Create A View

Jun 25, 2015

Log-in access web-page.When page is accessed a stored procedure is executed that will provide a list of all the RA(Problem -- when a new building is added, this stored procedure must be opened and syntax added)..Results are stored in a drop down list on the page.Create a table holds list of all buildings something similar to this

Create Table [dbo].[BuildingInformation] (
ID INT IDENTITY NOT NULL,
BuildingName varchar(50),
RAName varchar(50)

[code]....

Alter the stored procedure so that when it is run it will iterate the BuildingInformation table and compare the value in BuildingInformation to the values in the field BuildingName of the view [RA].  If all buildings contained in the table [BuildingInformation] exist in the view [RA] nothing will change.  If their are values in the [BuildingInformation] table that do not exist in the view [RA], the view [RA] will be dropped and recreate with a 'Union ALL' for each building in the table

View 6 Replies View Related

Transact SQL :: Query To Create New Column

Sep 2, 2015

I have a data with mutliple esn but different auditdate and opid. I will pull this data filtering by date and opid. My requirements is not to include the opid = 51 but need to get the desired opdesc for this esn that contains opid=51.

See below sample ddl and desired result. I dont want do include the opid = 51 because it will create a duplicate in transaction instead retain the opid 5

example: esn T9000000000019829505 has multiple rows with different auditdate and opid. retain the records for opid is equal to 5 but get the opdesc for opid is equal 51.

reate table #test
(esn nvarchar(35), dateaudit datetime, opid int)
insert into #test(esn,dateaudit, opid)values('352452060499834','2015-05-12 20:32:39.490',5)
insert into #test(esn,dateaudit, opid)values('352452060499834','2015-07-06 17:35:14.210',5)
insert into #test(esn,dateaudit, opid)values('T9000000000019829505','2015-01-14 15:18:45.620',5)

[Code] ....

Desired Result:

esn-------------------dateaudit----------------opid--opdesc--rn
352452060499834------2015-05-12 20:32:39.490---5---Shipping--1
352452060499834------2015-07-06 17:35:14.210--5---Shipping--1
T9000000000019829505--2015-01-14 15:18:45.620--5---Scrap-----1

OR

esn-------------------dateaudit----------------opid--opdesc--rn--remarks
352452060499834------2015-05-12 20:32:39.490---5---Shipping--1---shipping
352452060499834------2015-07-06 17:35:14.210--5---Shipping--1---shipping
T9000000000019829505--2015-01-14 15:18:45.620--5---Shipping--1---Scrap

View 5 Replies View Related

Transact SQL :: Create A User For Only One Database

Jul 17, 2015

I have a Java application (APP) that use SQL Server 2008 - 20014. In the SQL server there can be more than my database. During setup of the database the first user (ex:ADM) is created using MS SQL Server Management Studio (SMS). ADM can then launch the APP with proper credentials and connect to the database.ADM can then, in the APP, create new users for the APP and database. After some testing for proper CREATE and GRANTS I use the following code to create a new Create, Read, Update, Delete (CRUD) user for the APP and database: CREATE LOGIN testuser WITH PASSWORD='password', DEFAULT_DATABASE = testdb

USE testdb
CREATE USER testuser FOR LOGIN testuser
GRANT AUTHENTICATE TO testuser WITH GRANT OPTION
GRANT CONNECT TO testuser WITH GRANT OPTION
GRANT ALTER ANY USER TO testuser WITH GRANT OPTION
GRANT CONNECT SQL TO testuser WITH GRANT OPTION
GRANT INSERT,SELECT,UPDATE, EXECUTE, DELETE TO testuser WITH GRANT OPTION

USE master
GRANT CONTROL SERVER TO testuser

USE testdb..When I the use the SMS and look at security the "testuser" is only added to testdb. To test I create a second database "testdb2" --> launch the APP to connect to testdb2 and can login with "testuser".I don't know if I give to much grants or missing one...proper TSQL so new users only have CRUD access to "testdb" and no other database on the SQL server.

View 5 Replies View Related

Transact SQL :: How To Create Column Region

Oct 14, 2015

How to create column "Region" like this Picture.

View 16 Replies View Related

Transact SQL :: How To Create A 0-Many Relationship Between Two Tables

May 25, 2015

I have two tables, Inspections and InspectionDetails. The InspectionDetails only contains information if an inspection found violations. Some inspections don't look for violations so inspectiondetails would have no entry.How can I create a 0-Many relationship between these two tables?Inspection Table has : InspectionID, InspectionDate, TypeofInspection, Inspector..InspectionDetail Table has : DetailID (an auto-incrementing identity column), InspectionID, SectionViolated, ViolationDescription, InspectorNotes.

View 6 Replies View Related

Transact SQL :: Create Table With Timestamp Column

Jul 2, 2015

Im trying to insert the values from this query into a table, so I can later check the history of memory usage:

SELECT
[total_physical_memory_kb] / 1024 AS [Total_Physical_Memory_In_MB]
,[available_page_file_kb] / 1024 AS [Available_Physical_Memory_In_MB]
,[total_page_file_kb] / 1024 AS [Total_Page_File_In_MB]
,[available_page_file_kb] / 1024 AS [Available_Page_File_MB]
,[kernel_paged_pool_kb] / 1024 AS [Kernel_Paged_Pool_MB]
,[kernel_nonpaged_pool_kb] / 1024 AS [Kernel_Nonpaged_Pool_MB]
,[system_memory_state_desc] AS [System_Memory_State_Desc]
FROM [master].[sys].[dm_os_sys_memory]

What I'm missing is a way to insert the current timestamp every time I insert to the table.My plan is to use the insert into command.

View 3 Replies View Related

Transact SQL :: Create Alert Email From Query

Jun 21, 2015

How can I turn this query into an Email alert if one of the counts are GT 50. The Source are machines that I capture counts(Unprocessed_Cntr) from every 5 minutes and load to the Load_Time_Capture table. I also add a datetime to each capture(Unprocessed_Capture ).  

If any individual source has a count > 50 or if the combined(ALL) GT 50 send an email to support person.  

SELECT 
 CASE GROUPING([Source])
                  WHEN 1 THEN 'ALL'
                  ELSE [Source] END AS 'Input Source',           
                 avg([Unprocessed_Cntr]) as 'Average Queue Past 15 Min' 
                                      
FROM        Load_Time_Capture
WHERE Unprocessed_Capture >=  DateADD(mi, -15, Current_TimeStamp)
GROUP BY    [source] WITH ROLLUP

View 4 Replies View Related

Transact SQL :: Create Sequential Aggregate Of A Column Using Sum?

Aug 17, 2015

I need to create a sequential aggregate of a column using sum in tsql.

I want a column that will sum up all hours work by transaction date.

for example

Monday my hours work will be 8 and therefore my total transaction hours will be 8.

Tuesday my hours work will be 8 but I want the total hours of my total transaction hours to  16.

Wed my total hours work will be 5 and I want the total hours of my total transaction hours to  21. etc.

Select myname, weekday, hours worked, Totalhours_ToDate =Sum(hours worked)from table

View 3 Replies View Related

Transact SQL :: How To Create Stored Procedure Using Agent Job

May 8, 2015

I have 3rd party application implementation I am doing, if I have stored procedure in one database, can it be copied to other database (newly created) on the same server? I will have the name of old and new database when this will be copied. I do need to automate this copy.

View 10 Replies View Related

Transact SQL :: Create A View For Getting Rate What Was There On Said Period

May 13, 2015

table1

id Rate start end
A01 2 01/04/2015 31/03/2016
A02 2 01/04/2015 31/03/2016
A03 2 01/04/2015 31/03/2016
A01 2.5 01/04/2016 31/03/2017
A02 2.5 01/04/2016 31/03/2017
A03 2.5 01/04/2016 31/03/2017

table2

id Received
A02 13/05/2015
A02 23/07/2016

View 3 Replies View Related

Transact SQL :: Create Custom Work Day Calendar

Nov 17, 2015

I am wanting to create a custom workday calendar to show Monday - Friday as a workday, then go back and update a few holidays as non-workdays.  This is the syntax I have to start with, but it is presenting with an error:

Msg 241, Level 16, State 1, Line 21 Conversion failed when converting date and/or time from character string.

What should I alter?

CREATE TABLE dbo.CreateCustomCalendar
(
wk_Date INT IDENTITY NOT NULL,
FullDate DATETIME NOT NULL,
WeekDayName VARCHAR(9) NOT NULL,
IsWorkday varchar(20) NOT NULL
)

[Code]....

View 7 Replies View Related

Transact SQL :: Create Table Indexes In SSMS2012

May 26, 2015

I use Indexes Fundamentals of Microsoft SQL Server - Lesson 30: Indexes in the website of URL... to learn the basic things of Indexes. In my SQL Server 2012 Management Studio (SSMS2012), I executed the following code..

-- scFTX_CreateTableEmployees.sql
-- saved in C:/Documents/SQLServerIndexes_downloadCode
-- 26 May 2015 10:52 AM
USE ScottChangDB;
GO
CREATE TABLE Employees

[code]....

Where the SCHEMA and the index 'IX_Employees are located in the Object Explorer of the database "ScottChangDB" of my SSMS2012. 

View 3 Replies View Related

Transact SQL :: How To Create A Table Using Stored Procedure

Sep 1, 2015

Need creating a stored procedure which creates a table.

View 3 Replies View Related

Transact SQL :: Create Server Login In Bulk

Sep 29, 2015

I need to create a T-sql script to create logins in bulk so users can access views on the database. Usernames as used in the local domain are all stored in a table.

Users already exist in the domain (let’s say: MYDOMAIN)ADSI.dbo.Ad.username  is the column wich contains  the usernames as used in the Active Directory domain  (+/- 350)Script needs to check if login already exists to make sure login is not added twice.If possible give all these users db_datareader role, in let’s say: MYDATABASE

View 7 Replies View Related

Transact SQL :: Create Join On Aliased Column

Jun 20, 2015

This is my syntax, but it keeps presenting an error of 'Invalid Column name Last Resort

Select fb.foo, fb.man, cz.choo, 'Hi' As [Last Result]
From foobar As fb
Inner Join chezter As cz
On fb.username = cz.username
and [fb].[Last Result] = [cz].[Last Result]

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved