Comment To Table
Mar 26, 2008Hello,
can I create a comment for a table in SQL Server 2005? For a column I can create a comment in the description-field.
finchen
Hello,
can I create a comment for a table in SQL Server 2005? For a column I can create a comment in the description-field.
finchen
Hi there gurus, can you please add your 2 cents on this design? We'rehaving trouble relating these tables in a diagram because of the keys.Is it necesary to have the references setup? I would assume yes so theforign keys can be setup.If you look at this link, you'll see our diagram. In Red are therelationships that we would like to make for referential integrity, butcannot because of the keys.http://rullo.ca/linktome/QuestionsDB.jpgOur goal in all of this is to have a facility wherin we can store aquestion, that has multiple names over multiple Languages. Forinstance:-Q1| QNameID = 1 | "Do you have a dog in your appartment?" | LangID =1(eng)-Q1| QNameID = 2 | "Do you have a dog in your house?" | LangID =1(eng)-Q1| QNameID = 1 | "-French - Do you have a chien in your appartment?"| LangID = 2(fr)-Q1| QNameID = 2 | "-French - Do you have a chien in your house?" |LangID = 2(fr)The difficulty is when we try and put this in the group details table.We don't want to outline the Language, we'd just pass the language intoa proc to retreive a specific group with a specific language. If youfolks would be so kind as to add your comments to the design I would betruely grateful.CREATE TABLE [Question] ([QuestionID] [int] NOT NULL ,[SystemName] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOTNULL ,CONSTRAINT [PK_Question] PRIMARY KEY CLUSTERED([QuestionID]) ON [PRIMARY]) ON [PRIMARY]GOCREATE TABLE [QuestionAnswer] ([QuestionID] [int] NOT NULL ,[QuestionAnswerID] [int] NOT NULL ,[SystemName] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOTNULL ,CONSTRAINT [PK_QuestionAnswer] PRIMARY KEY CLUSTERED([QuestionID],[QuestionAnswerID]) ON [PRIMARY] ,CONSTRAINT [FK_QuestionAnswer_Question] FOREIGN KEY([QuestionID]) REFERENCES [Question] ([QuestionID])) ON [PRIMARY]GOCREATE TABLE [QuestionAnswerName] ([QuestionAnswerID] [int] NOT NULL ,[QuestionAnswerNameID] [int] NOT NULL ,[LanguageID] [int] NOT NULL ,[Name] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,CONSTRAINT [PK_QuestionAnswerName] PRIMARY KEY CLUSTERED([QuestionAnswerID],[QuestionAnswerNameID],[LanguageID]) ON [PRIMARY]) ON [PRIMARY]GOCREATE TABLE [QuestionGroup] ([QuestionGroupID] [int] NOT NULL ,[Name] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,CONSTRAINT [PK_QuestionGroup] PRIMARY KEY CLUSTERED([QuestionGroupID]) ON [PRIMARY]) ON [PRIMARY]GOCREATE TABLE [QuestionGroupDetails] ([QuestionGroupID] [int] NOT NULL ,[QuestionNameID] [int] NOT NULL ,[QuestionAnswerNameID] [int] NOT NULL ,[QuestionSortOrder] [int] NULL ,[AnswerSortOrder] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_ASNULL ,[DisplayLevel] [int] NULL ,CONSTRAINT [PK_QuestionGroupDetails] PRIMARY KEY CLUSTERED([QuestionGroupID],[QuestionNameID],[QuestionAnswerNameID]) ON [PRIMARY] ,CONSTRAINT [FK_QuestionGroupDetails_QuestionGroup1] FOREIGN KEY([QuestionGroupID]) REFERENCES [QuestionGroup] ([QuestionGroupID])) ON [PRIMARY]GOCREATE TABLE [QuestionNames] ([QuestionID] [int] NOT NULL ,[QuestionNameID] [int] NOT NULL ,[LanguageID] [int] NOT NULL ,[Name] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,[Desciption] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,[ControlTypeID] [uniqueidentifier] NOT NULL ,CONSTRAINT [PK_QuestionNames] PRIMARY KEY CLUSTERED([QuestionID],[QuestionNameID],[LanguageID]) ON [PRIMARY] ,CONSTRAINT [FK_QuestionNames_Question] FOREIGN KEY([QuestionID]) REFERENCES [Question] ([QuestionID])) ON [PRIMARY]GO
View 1 Replies View RelatedHey guys,
I have a Access adp that backs onto SQL Server 2005, its taken a while but tis nearly done.
Just one last thing to figure out.. and thats how to send a email. I had a look at all the Access ways and they just wont work out for this.
So I decided to use the server to send them, I would insert/update a row into a table which has a trigger on it.
The table has amoung other things a Approved and Declined column.
Both at 0 Sends an email to an Approver
App 1 Dec 0 Sends on further
and App 0 Dec 1 sends back to the original sender.
All I really want to know is could a trigger execute a package or something that will send the email? (Yes thats right someone isnt asking for code for once:D meh must be winter in hell)
If theres any flaws in my idea please feel free to tell me (Saves me denting the desk with my head half a week and 10 pages of code from now)
And where do I create triggers:P (Will probly have found this one in BOL by the time anyone replys)
Sorry about this but I really have no clue about triggers.. seems the site doesnt like me searching for triggers
'This page was generated in 17.03 seconds.'
:P
Hi
i have a comment column which is varchar(200). when a user types any say for example a couple of small paragraph with commas , colon, hard enter key.
when i run a select statement and save it to csv file and then open with excel, if the comments has comma then i get these info in separate column and if there is hard enter key then it goes into new line.
Is there a way to get these info in one column
Thanks,
Hai friendsCould u pleas give me some noites on replication . I worked out thruwizards but not succeded.With thanksRaghu
View 1 Replies View RelatedPlesae tell me the MSSQL Server equivalent of the below MySQL query .create table temp2(a varchar(23) comment 'male m');What is the use of specifying a keyword 'comment' in the column definition. Will it make any difference
View 14 Replies View RelatedI want to get the latest comment for each id based on the maximum createdDate and not sure how to do this, tried to do Max but it was still returning all the rows.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Audit](
[id] [nvarchar](64) NOT NULL,
[Code] ....
I have looked everywhere for an answer for this one, so if it's out there and I've missed it, sorry.
I want to include a list of instructions with a report that I am sending out to a list of subscribers (not Data Driven, each is an individual subscription). It seems no matter how I enter the text in the Comments box, the body of the email comes out as a continuous stream of text with no line breaks, which is difficult for the recipients to read.
Is there a way to embed line breaks as a minimum, but preferrably additional formatting, in a subscription comment?
Thanks
Trevor
Hi,
Can any tell me how to check whether any Comment been entered in a Cell in the Excel Sheet?
It is pretty urgent. Solutions are greatly appreciable.
Thanks & Regards,
Prakash Srinivasan.
The following sql works great when the field for my main blog message is type nvarchar but doesn't work for text which I need to convert to.
select
a.id, b.textField
count(b.a_id) as myCount
from a left join b on a.id = b.a_id
group by a.id, b.textField
What other methods could i use to get "myCount" within one sql statement?
Thanks in advance, Jeff
inserted a record with an identity field
I had a '-- comment' right
Select @data = @@identity
This select failed - @data was NULL
I changed it to SET @data = @@identity
This also failed @data was null
I then change to the follow which worked - Why would the different form of a
comment make a difference? I was the only one in the database, there were no
other changes. I could make the logic block fail or succed by just changing
the comment syntax.
inserted a record with an identity field
I had a '/** comment**/' right
Select @data = @@identity
I am setting up a data driven subscription to send out an email which includes a report. The Sql for the data driven subscription outputs the EmailTo, Subject, Comment(Body) and some report parameters. My issue is with the Comment (Body) field which I would like to format with CR/LF to make the email body look neat and readable. I've tried many different permutations of inserting the CR/LF, From concatenating Char(13) + Char(10) in which the email does recognize the Cr/LF to concatenating binary 0x0D + 0x0A which after the first concatenation of binary nothing else can be concatenated. Here is the code I've tried:
---~~~~~~~~
declare @iEndDate datetime
set @iEndDate = dbo.fn_today()
Declare @Account_group int
Set @Account_group = 999
/*
DECLARE @mybin1 binary(5), @mybin2 binary(5)
SET @mybin1 = 0x0D
SET @mybin2 = 0x0A
*/
Declare @CrLf VarChar(5)
set @CrLf = CHAR(13) + CHAR(10)
Declare @Str1 VarChar(255)
Declare @Str2 VarChar(255)
Declare @Str3 VarChar(255)
Declare @Str4 VarChar(255)
Declare @Str5 VarChar(255)
Declare @Str6 VarChar(255)
Declare @Str7 VarChar(255)
Declare @Str8 VarChar(255)
Declare @Str9 VarChar(255)
Set @Str1 = 'Good Morning,'
Set @Str2 = 'We are exposed by '
Set @Str3 = 'Attached please find the margin call detail.'
Set @Str4 = 'Please let us know if you have any questions.'
Set @Str5 = 'Thank you.'
Set @Str6 = 'Please respond to:'
Set @Str7 = ''
Set @Str8 = ''
Set @Str9 = ''
declare @t table
(
EmailTo VarChar(255),
ReplyTo VarChar(255),
Subject VarChar(255),
Comment Text,
Account_group Int,
Trading_Account_Id Int,
Broker_Code_Ky VarChar(255),
EndDate Datetime
)
insert into @t
select
EmailTo = '', -- isnull(bf.firm_email,''),
ReplyTo = '',
Subject = 'Margin Call Notice: - ' + Trading_account_name + ' - Exposure: ' + '$' + Convert(varchar(20), convert(Money, Mark_amount),1) ,
Comment = @Str1 + @CrLf + @CrLf + @Str2 + '$' + Convert(varchar(20), convert(Money, Mark_amount),1) + '.' + @CrLf + @CrLf + @Str3 + @CrLf + @CrLf + @Str4 + @CrLf + @CrLf + @Str5 + @CrLf + @CrLf + @Str6 + @CrLf + @Str7+ @CrLf + @Str8 + @CrLf + @Str9,
Account_group = @Account_group,
Trading_Account_Id = trading_account_Id,
Broker_Code_Ky = EGS.Broker_Code_Ky,
EndDate = @iEndDate
from fni_ExposureGovernmentSummary (@iEndDate) EGS
join broker_group bg
on EGS.broker_code_ky = bg.broker_code_ky
Join broker_firm bf
on bg.fbe_firm_id = bf.broker_firm_id
Order by
Broker_Group_Name,
Trading_account_Name
select top 2 * from @t
--~~~~~~~~~~~~~
The Email my company is using is Lotus Notes.
The Question is how do I code the the Comment field so that my email will recognize the Cr/LF.
Thanks
Elias
Hi, experts,
How can we add comment which only appears on the first page of the report?
I am looking forward to hearing from you for your help and thanks a lot in advance.
With kindest regards,
Yours sincerely,
Hi all,
I have a report where I have to display State, Category Name and the text. Below is the sample report
State Category Name Text
TX Unanticipated High NT due to RADD clean up- drive replacement.
NJ Unanticipated SAR efforts (SEM configuration)
But now my question is if there is no comment in any other state I would like to show no comment in the text line. Is there any formula I can use in the report level that will take care of the issue. I know in Business object there is a formula you can create which is =If (IsNull([Text]);"No Comments Reported";[Text]). I need to know in ssrs there is something.
please let me know ASAP and the steps of doing that.
Thanks
Rozarm02
We just encountered an odd failure in ADODB. If it gets an SQL query with a comment embedded in it, and the comment has an apostrophe as one of the characters, ADODB gets confused as it tries to plug in parameters for placeholders later in the query. For example:
SELECT id, name
FROM doc_type /* this won't work! */
WHERE name LIKE ?
If you take out the apostrophe ("this will not work!") or move the comment to follow the placeholder, the query works.
Is this a known bug (couldn't find it in the KB)?
Thanks,
Bob Kline
I am running SQL Server 2005 SP2 and I am getting an SQL error due to the server not recognizing the "--" as a comment. (I am using the 32-bit version) The same code runs on SQL Server 2000 with no problem.
Is there a setting to correct this? Do I need to install the cumulative update pkg 3 to correct this problem?
My God! What happens if I miss a step, or put it in a different order??? I know I can specify ORDER BY StepID, but what about a missing step? I do have "missing ranges" script, but posting questions filtered through the script process may become a full-time job in itself...What to do, what to do...
View 14 Replies View RelatedHi,Is there anyone encountered this error before & how it is being resolved?[Microsoft][ODBC SQL Server Driver][SQL Server]Missing end comment mark '*/'The error pops-up when I was running a DTS Import/Export from a SQL server(source) to another SQL server (destination) residing on a differentmachine. I'm copying all tables, views, & stored procedures of a database.Thanks for any input.Regards,Maricel
View 1 Replies View RelatedI have a field that contains some text. Each field will have none or atleast one comment in it. A comment can be a string of any length with *** on both sides. Ex: ***comment***
Declare @Test_tbl Table(TextField Text)
Insert Into @Test_tbl
Select 'Some text ***comment*** some more text' Union all
Select 'Other text ***another comment*** more and more text' Union all
Select '***Comment*** some text ***More Comments***' Union all
Select 'some text with no comment'
I need the output be ...
TextField
--------------
Some text some more text
Other text more and more text
some text
some text with no comment
Thanks in advance.
All- I'm a newbie working on a VWD project. A couple questions arose when attempting to work with a project's dataset and its underlying SQL Server Express database:
Is it true that when changing the schema of a database in SQL Server Express through the VWD Database Explorer, one must take care to manually make parallel changes in the dataset? For example, if you make a relation between two tables in Database Explorer, you must do the same with the counterpart tables in the dataset? For example, I find that if I delete or create a relationship between two tables in the database, I must manually do the same in the dataset.
i am testing some encryption
scenarios ,in profiler the statements like "OPEN KEY" and all "Encrypt"
and "Decrypt" functions are removed automaticly from the trace
and replaced with a comment ,create a trace and try the code i attached ,
you will see in profiler trace that that all encryption related commands
are commented out ,this is what expected.
but now go to the batch and comment out the "SELECT @rrr' statment,
and run the batch ,this batch will fail beacuse "@rrr" is not declared,
now go back to profiler and you will see that for the failed batch
all the encryption command are NOT COMMENTED OUT !!!
esspecially important is the visibility of the password of the open key command.
seems like a very dangerous bug to me!!!
CREATE CERTIFICATE test1
ENCRYPTION BY PASSWORD = 'pGFD4bb925DGvbd2439587y'
WITH SUBJECT = 'Sammamish Shipping Records',
EXPIRY_DATE = '10/31/2009';
GO
CREATE SYMMETRIC KEY Key09 WITH ALGORITHM = TRIPLE_DES
ENCRYPTION BY CERTIFICATE test1;
GO
declare @Str nvarchar(100)
declare @Enc varbinary(max)
set @Str = 'encrypt this'
OPEN SYMMETRIC KEY Key09
decryption by CERTIFICATE test1 WITH PASSWORD = 'pGFD4bb925DGvbd2439587y'
SET @Enc
= EncryptByKey(Key_GUID('Key09'), @Str);
---select @rrr
select CONVERT(nvarchar(100), DecryptByKey(@Enc))
go
I have recently started using replication in SQL 2012 SP1. When a stored procedure is altered on the source, the changes are replicated to the subscribers; however, the comment headers are removed at the subscribers. Due to the vast number of stored procedures I have, I do not want to move the comments below the Create Procedure statement. Are there any other ways to have comment header move with the stored procedures?
Here is what I am experiencing
Source SP
ALTER PROCEDURE [dbo].[SPTest]
AS
BEGIN
SELECT GETDATE()
END
Destination SP
ALTER PROCEDURE [dbo].[SPTest]
AS
BEGIN
SELECT GETDATE()
END
Hello everyone!!
I am completely new to SSIS and have been given a large project (of course with a tight deadline) that has the absolute requirement of using SSIS. I am/was very, very good with DTS and could easily accomplish what I need to do with an ActiveX script task in DTS in no time, but as this is new development, we are not to use ActiveX script tasks within SSIS since it will not be supported in the next SQL Server release. I'm thinking script task, but please give some comments on how you would accomplish the following in SSIS (please remember I'm new to SSIS, so don't assume I know anything. )
I must accomplish this: in a nutshell, I need to create separate tab delimited text files of customer informaion. One for each region. Each region consists of X amount of states and we have X amount of regions. (Pseudo code followed by standard explanation)
Select a max value from region lookup table in SQL (this is the # of regions)
for N=1 to MyMaxValue
select states from region lookup table where region code = N (the current region we are on)
'this returns a list of states in a region, need these in array or recordset object or something
Open an output file which will be a tab delimited text file we will write results below in loop to (in DTS I would programatically kick off a transformation task in the package)
'loop thru states returned, so if in a rs object...
do while not rs.eof
execute customer stored procedure, passing as a variable the current state we are on
'this will return all customers within a state, this whole result set (approx 1 million) needs to go to the tab delimited file
'I have to execute this stored procedure for each state & then write results to the SAME file, until we are onto a different region
rs.movenext
close file
loop
next
OK, so basically, as you can see, Its sort of simple in a way what I need to do, i just have no idea how to go about doing this in SSIS. I can not hard code any state or region values. I MUST read them in from the lookup tables as region codes are constanatly changing and we are constantly adding in new states and new regions, so with above coding idea, it would always dynamically pick up any new states, new regions or changes.
So in a nutshell, I need to create separate tab delimited text files of customer informaion. One for each region. Each region consists of X amount of states and there are X amount of regions. Pretty strait forward, huh? The requirements are strait forward, but SSIS is throwing me for a loop... it does not seem flexible enough to be as dynamic as I need it to be to do this. I'm sure it is, just my understanding of it is very basic so far.
Please provide your suggestions! I think a lot of newbies would benefit from some SSIS design info... how to do common things in SSIS, but beyond just retrieving a recordset and writing it to a file... what do you do when you need to add just a few layers of decision processing, and retriving recordsets and writing files based on that decision processing?????
THANK YOU!!!!!!
Kathy
I am using SQL Server 2005 and trying to create a linked server on Oracle 10. I used the commands below:
EXEC sp_addlinkedserver
@server = 'test1',
@srvproduct = 'Oracle',
@provider = 'MSDAORA',
@datasrc = 'testsource'
exec sp_addlinkedsrvlogin
@rmtsrvname = 'test1',
@useself = 'false',
@rmtuser='sp',
@rmtpassword='sp'
When I execute
select * from test1...COUNTRY
I get the error. "The OLE DB provider "MSDAORA" for linked server "...." does not contain the table "COUNTRY". The table either does not exist or the current user does not have permissions on that table."
The 'sp' user I am connecting is the owner of the table. What could be the problem ?
Thanks a lot.
I have created a table Table with name as Varchar and id as int. Now i have started inserting the rows like, insert into Table values ('arun',20).Yes i have inserted a row in the table. Now i have got the values " arun's ", 50. insert into Table values('arun's',20) My sqlserver is giving me an error instead of inserting the row. How will you solve this problem?
Hi
I am having a table called as status ,in that table one field is there i.e. currentstatus.
the rows which are having currentstatus as "ticket closed",i want to move those rows into other table called repository which is having same table structure as status table.
I can do programatically.
but is there any way for every 3 months system has to check and do this action means moving to repository table automatically?
Please help me.
Thanks.
I'm inserting from TempAccrual to VacationAccrual . It works nicely, however if I run this script again it will insert the same values again in VacationAccrual. How do I block that? IF there is a small change in one of the column in TempAccrual then allow insert. Here is my query
INSERT INTO vacationaccrual
(empno,
accrued_vacation,
accrued_sick_effective_date,
accrued_sick,
import_date)
[Code] ....
For reasons that are not relevant (though I explain them below *), Iwant, for all my users whatever privelige level, an SP which createsand inserts into a temporary table and then another SP which reads anddrops the same temporary table.My users are not able to create dbo tables (eg dbo.tblTest), but arepermitted to create tables under their own user (eg MyUser.tblTest). Ihave found that I can achieve my aim by using code like this . . .SET @SQL = 'CREATE TABLE ' + @MyUserName + '.' + 'tblTest(tstIDDATETIME)'EXEC (@SQL)SET @SQL = 'INSERT INTO ' + @MyUserName + '.' + 'tblTest(tstID) VALUES(GETDATE())'EXEC (@SQL)This becomes exceptionally cumbersome for the complex INSERT & SELECTcode. I'm looking for a simpler way.Simplified down, I am looking for something like this . . .CREATE PROCEDURE dbo.TestInsert ASCREATE TABLE tblTest(tstID DATETIME)INSERT INTO tblTest(tstID) VALUES(GETDATE())GOCREATE PROCEDURE dbo.TestSelect ASSELECT * FROM tblTestDROP TABLE tblTestIn the above example, if the SPs are owned by dbo (as above), CREATETABLE & DROP TABLE use MyUser.tblTest while INSERT & SELECT usedbo.tblTest.If the SPs are owned by the user (eg MyUser.TestInsert), it workscorrectly (MyUser.tblTest is used throughout) but I would have to havea pair of SPs for each user.* I have MS Access ADP front end linked to a SQL Server database. Forreports with complex datasets, it times out. Therefore it suit mypurposes to create a temporary table first and then to open the reportbased on that temporary table.
View 6 Replies View RelatedHi all,
The following dbo.Tables of Northwind.mdf in my .SQLEXPRESS (SQL Server Management Studio Express) are missing:
dbo.Categories
dbo.CustomerCustomerDemo
dbo.CustomerDemographics
dbo.Customers
dbo.Employees
dbo.EmployeeTerritories
dbo.Order Details
dbo.Orders
dbo.Products
dbo.Regions
dbo.Shippers
dbo.Suppliers
dbo.Territories.
But, I have these dbo.Tables in a different Database "xyzDatabase". How can I copy each of these dbo.Tables to the another blank dbo.Table of Northwind Database?
I right clicked on the dbo.Categories and I saw the following thing:
dbo.Categories
New Table...
Modify
Open Table
Script Table as |> CREATYE To |>
DROP To |>
SELECT To |>
INSERT To |> New Query Editor Window
File....
Clipboard
UPDATE To |>
DELETE to |>
From the above observation,I think it is possible to copy the dbo.Table from the one Database to the Northwind Database that needs to be repaired. Please help and advise me how to do this task or tell me where I can find the Microsoft document that gives the details of this X-copy thing.
Thanks in advance,
Scott Chang
P. S. I am using VB 2005 Express to create a project to learn "Calling Stored Procedures with ADO.NET" (see Paul Kimmel's article in http://www.developer.com/db/article.php/3438221) that needs the dbo.Tables of Northwind Database and my Northwind Database has been screwed up for quite a while and needs a big repair.
which is more efficient...which takes less memory...how is the memory allocation done for both the types.
View 1 Replies View Related'****************************************************************************
Cmd.CommandText = "Drop Table Raj"
Cmd.ExecuteNonQuery()
Cmd.CommandText = "Select * Into Raj From XXX"
Cmd.ExecuteNonQuery()
'**************************************************************************
This generates error that Table already exist.
If Wait 1 sec then execute statement then it works fine.
Thanks in Advance
Piyush Verma
I have one control table to store all related table name
Table ID TableName
1 TableA
2 TableB
In Table A:
RecordID Value
1 1
2 2
3 3
In Table B:
RecordID Value
1 1
2 2
3 3
How can I get the result by select the Table list first and then combine the data in table A and table B?
Thank you!
Just wondering if there is an easy transact statement to copy table 1 to table 2, appending the data in table 2.with SQL2000, thanks.
View 2 Replies View Related