Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Wednesday, March 28, 2012

Install on alternate TCP Port

I am trying to create an unattended install of MSDE 2000 sp3a that will set the default tcp port to something other than 1433. I am using a setup.ini file and have tried the following with out any success - any ideas would be great! Thanks
[Options]
SECURITYMODE=SQL
DISABLENETWORKPROTOCOLS=0
[SdServerNetwork-0]
TCPPort=1433
hi Kelly
"Kelly" <anonymous@.discussions.microsoft.com> ha scritto nel messaggio
news:D1F4F952-218E-46F9-BF44-ED0F083F0AAD@.microsoft.com...
> I am trying to create an unattended install of MSDE 2000 sp3a that will
set the default tcp port to something other than 1433. I am using a
setup.ini file and have tried the following with out any success - any ideas
would be great! Thanks
> [Options]
> SECURITYMODE=SQL
> DISABLENETWORKPROTOCOLS=0
> [SdServerNetwork-0]
> TCPPort=1433
the MSDE 2000 setup boostrapper does not support TCP/IP port redirecting
the
[SdServerNetwork-0]
TCPPort=1433
parameter you provided is only valid for a full blown SQL Server unattended
installations and not for MSDE...
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.7.0 - DbaMgr ver 0.53.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Thanks Andrea!
What is the best method to change the tcp port after MSDE has been installed on the client machine?
Is it acceptable to modify the TcpPort via the registry:
HKLM\Software\Microsoft\MSSQLServer\SuperSocketNet Lib\Tcp
|||hi Kelly,
"Kelly" <anonymous@.discussions.microsoft.com> ha scritto nel messaggio
news:36ACB0E9-2A4E-45A1-A0A3-C430B364D324@.microsoft.com...
> Thanks Andrea!
> What is the best method to change the tcp port after MSDE has been
installed on the client machine?
> Is it acceptable to modify the TcpPort via the registry:
> HKLM\Software\Microsoft\MSSQLServer\SuperSocketNet Lib\Tcp
this can be a viable solution as, in order to install MSDE, admin privileges
are required, so you have access to the full registry, but remember you have
to modify that value using the Client Network Utility on all clients...
as regard the server, please have a look at
http://support.microsoft.com/?kbid=823938
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.7.0 - DbaMgr ver 0.53.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Thanks for all of your help

Friday, March 23, 2012

install integration service on existing instance

I need to install Integration Service on an existing SQL 2005 instance. Is
it possible add components to an existing instance or do I need to create a
new instance of SQL server?
When you install SSIS on a Server, the service is "stand alone", not bound to
a specific instance. You can install SSIS alone, running the setup and asking
for the installation of the Integration services without install the other
components
Gilberto Zampatti
"Mike" wrote:

> I need to install Integration Service on an existing SQL 2005 instance. Is
> it possible add components to an existing instance or do I need to create a
> new instance of SQL server?
>
>

install integration service on existing instance

I need to install Integration Service on an existing SQL 2005 instance. Is
it possible add components to an existing instance or do I need to create a
new instance of SQL server?When you install SSIS on a Server, the service is "stand alone", not bound t
o
a specific instance. You can install SSIS alone, running the setup and askin
g
for the installation of the Integration services without install the other
components
Gilberto Zampatti
"Mike" wrote:

> I need to install Integration Service on an existing SQL 2005 instance. Is
> it possible add components to an existing instance or do I need to create
a
> new instance of SQL server?
>
>

install integration service on existing instance

I need to install Integration Service on an existing SQL 2005 instance. Is
it possible add components to an existing instance or do I need to create a
new instance of SQL server?When you install SSIS on a Server, the service is "stand alone", not bound to
a specific instance. You can install SSIS alone, running the setup and asking
for the installation of the Integration services without install the other
components
Gilberto Zampatti
"Mike" wrote:
> I need to install Integration Service on an existing SQL 2005 instance. Is
> it possible add components to an existing instance or do I need to create a
> new instance of SQL server?
>
>sql

Monday, March 19, 2012

Installation - How do you get it to run?

I have downloaded the SQLce package from Microsoft and have run the .msi file.

How do I actually start the product and create tables and data?

Thanks,
Fred

You can't. It only really runs as part of your code (or someone else's).

If you want to create tables, etc. you're probably going to want to use SQL Server Management Studio, the express version is free.

Install both SQL Server 2005 Developer and SQL Express on same mac

I currently have Visual Studio 2005 and SQL Server 2005 Developer installed
on my XP Professional PC. I'm trying to create a Visual Studio project that
uses a local database within the application. When I try to add the SQL
database "item" to my project, I get the following error: "Connections to SQL
Server files (*.mdf) require SQL Server Express 2005 to function properly.
Please verify the installation of the component or download from the URL
http://go.microsoft.com/wlink/?linkID=49251"
I understand that SQL Express is required so I can deploy the application to
a customer's PC that does not have SQL Server installed, and since SQL
Express is free, it's the logical choice for this sort of application. My
problem comes when I try to install SQL Express on my PC. Every time I
attempt to install, it wants to completely remove SQL Server 2005 Developer.
I keep reading that I can have both editions installed on one machine, but I
can't figure out how to do it. I don't want to uninstall the Developer
edition. Can anyone out there please explain how I can do it?
Thanks.
You certainly can install both SQL Server2005 full version and SQL Server
Express on the same computer. However, if you have the developer edition
installed already, you probably do not need to install SQL Server Express to
take up your crowded disk drive space.
I strongly suggest you to do some study on SQL Server, if you are to use it
in your development. The said error message is caused by using "User
Instance" feaure, only available to SQL Server Express, which you probably
do not need to use (unless you do know what User Instance is and have to use
it in your application).
SQL Server is installed on a computer by instance, and multiple instances
are allowed. Only one instance can be default instance, meaning uses
computer name as SQL Server's instance name, all other SQL Server
installations have to be named instance (in the form of "ComputerName\SQL
ServerInstanceName").
"ginacresse" <ginacresse@.discussions.microsoft.com> wrote in message
news:6E2CB76C-BD03-47E5-B3EB-B0A26834B8F7@.microsoft.com...
>I currently have Visual Studio 2005 and SQL Server 2005 Developer installed
> on my XP Professional PC. I'm trying to create a Visual Studio project
> that
> uses a local database within the application. When I try to add the SQL
> database "item" to my project, I get the following error: "Connections to
> SQL
> Server files (*.mdf) require SQL Server Express 2005 to function properly.
> Please verify the installation of the component or download from the URL
> http://go.microsoft.com/wlink/?linkID=49251"
> I understand that SQL Express is required so I can deploy the application
> to
> a customer's PC that does not have SQL Server installed, and since SQL
> Express is free, it's the logical choice for this sort of application. My
> problem comes when I try to install SQL Express on my PC. Every time I
> attempt to install, it wants to completely remove SQL Server 2005
> Developer.
> I keep reading that I can have both editions installed on one machine, but
> I
> can't figure out how to do it. I don't want to uninstall the Developer
> edition. Can anyone out there please explain how I can do it?
> Thanks.
|||On Jul 25, 4:29 pm, "Norman Yuan" <NotR...@.NotReal.not> wrote:
Thank you Norman Yuan.
I will keep what you said in mind for future reference.
Just the other day, I too tried to install SQL Server 2005 Developer
Edition onto my XP Pro machine, which already has the SQL Server 2005
Express (Free) edition, and the installation failed at the very end--
$50 wasted buying the Developer edition. But so far I've not missed
Developer Edition anyway in my software programming (differences
between the editions found here: http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx
, with Developer being like Enterprise for the most part)
RL

Install both SQL Server 2005 Developer and SQL Express on same mac

I currently have Visual Studio 2005 and SQL Server 2005 Developer installed
on my XP Professional PC. I'm trying to create a Visual Studio project that
uses a local database within the application. When I try to add the SQL
database "item" to my project, I get the following error: "Connections to SQ
L
Server files (*.mdf) require SQL Server Express 2005 to function properly.
Please verify the installation of the component or download from the URL
http://go.microsoft.com/wlink/?linkID=49251"
I understand that SQL Express is required so I can deploy the application to
a customer's PC that does not have SQL Server installed, and since SQL
Express is free, it's the logical choice for this sort of application. My
problem comes when I try to install SQL Express on my PC. Every time I
attempt to install, it wants to completely remove SQL Server 2005 Developer.
I keep reading that I can have both editions installed on one machine, but I
can't figure out how to do it. I don't want to uninstall the Developer
edition. Can anyone out there please explain how I can do it?
Thanks.You certainly can install both SQL Server2005 full version and SQL Server
Express on the same computer. However, if you have the developer edition
installed already, you probably do not need to install SQL Server Express to
take up your crowded disk drive space.
I strongly suggest you to do some study on SQL Server, if you are to use it
in your development. The said error message is caused by using "User
Instance" feaure, only available to SQL Server Express, which you probably
do not need to use (unless you do know what User Instance is and have to use
it in your application).
SQL Server is installed on a computer by instance, and multiple instances
are allowed. Only one instance can be default instance, meaning uses
computer name as SQL Server's instance name, all other SQL Server
installations have to be named instance (in the form of "ComputerName\SQL
ServerInstanceName").
"ginacresse" <ginacresse@.discussions.microsoft.com> wrote in message
news:6E2CB76C-BD03-47E5-B3EB-B0A26834B8F7@.microsoft.com...
>I currently have Visual Studio 2005 and SQL Server 2005 Developer installed
> on my XP Professional PC. I'm trying to create a Visual Studio project
> that
> uses a local database within the application. When I try to add the SQL
> database "item" to my project, I get the following error: "Connections to
> SQL
> Server files (*.mdf) require SQL Server Express 2005 to function properly.
> Please verify the installation of the component or download from the URL
> http://go.microsoft.com/wlink/?linkID=49251"
> I understand that SQL Express is required so I can deploy the application
> to
> a customer's PC that does not have SQL Server installed, and since SQL
> Express is free, it's the logical choice for this sort of application. My
> problem comes when I try to install SQL Express on my PC. Every time I
> attempt to install, it wants to completely remove SQL Server 2005
> Developer.
> I keep reading that I can have both editions installed on one machine, but
> I
> can't figure out how to do it. I don't want to uninstall the Developer
> edition. Can anyone out there please explain how I can do it?
> Thanks.|||On Jul 25, 4:29 pm, "Norman Yuan" <NotR...@.NotReal.not> wrote:
Thank you Norman Yuan.
I will keep what you said in mind for future reference.
Just the other day, I too tried to install SQL Server 2005 Developer
Edition onto my XP Pro machine, which already has the SQL Server 2005
Express (Free) edition, and the installation failed at the very end--
$50 wasted buying the Developer edition. But so far I've not missed
Developer Edition anyway in my software programming (differences
between the editions found here: http://www.microsoft.com/sql/prodin...e-features.mspx
, with Developer being like Enterprise for the most part)
RL

Install both SQL Server 2005 Developer and SQL Express on same mac

I currently have Visual Studio 2005 and SQL Server 2005 Developer installed
on my XP Professional PC. I'm trying to create a Visual Studio project that
uses a local database within the application. When I try to add the SQL
database "item" to my project, I get the following error: "Connections to SQL
Server files (*.mdf) require SQL Server Express 2005 to function properly.
Please verify the installation of the component or download from the URL
http://go.microsoft.com/wlink/?linkID=49251"
I understand that SQL Express is required so I can deploy the application to
a customer's PC that does not have SQL Server installed, and since SQL
Express is free, it's the logical choice for this sort of application. My
problem comes when I try to install SQL Express on my PC. Every time I
attempt to install, it wants to completely remove SQL Server 2005 Developer.
I keep reading that I can have both editions installed on one machine, but I
can't figure out how to do it. I don't want to uninstall the Developer
edition. Can anyone out there please explain how I can do it?
Thanks.You certainly can install both SQL Server2005 full version and SQL Server
Express on the same computer. However, if you have the developer edition
installed already, you probably do not need to install SQL Server Express to
take up your crowded disk drive space.
I strongly suggest you to do some study on SQL Server, if you are to use it
in your development. The said error message is caused by using "User
Instance" feaure, only available to SQL Server Express, which you probably
do not need to use (unless you do know what User Instance is and have to use
it in your application).
SQL Server is installed on a computer by instance, and multiple instances
are allowed. Only one instance can be default instance, meaning uses
computer name as SQL Server's instance name, all other SQL Server
installations have to be named instance (in the form of "ComputerName\SQL
ServerInstanceName").
"ginacresse" <ginacresse@.discussions.microsoft.com> wrote in message
news:6E2CB76C-BD03-47E5-B3EB-B0A26834B8F7@.microsoft.com...
>I currently have Visual Studio 2005 and SQL Server 2005 Developer installed
> on my XP Professional PC. I'm trying to create a Visual Studio project
> that
> uses a local database within the application. When I try to add the SQL
> database "item" to my project, I get the following error: "Connections to
> SQL
> Server files (*.mdf) require SQL Server Express 2005 to function properly.
> Please verify the installation of the component or download from the URL
> http://go.microsoft.com/wlink/?linkID=49251"
> I understand that SQL Express is required so I can deploy the application
> to
> a customer's PC that does not have SQL Server installed, and since SQL
> Express is free, it's the logical choice for this sort of application. My
> problem comes when I try to install SQL Express on my PC. Every time I
> attempt to install, it wants to completely remove SQL Server 2005
> Developer.
> I keep reading that I can have both editions installed on one machine, but
> I
> can't figure out how to do it. I don't want to uninstall the Developer
> edition. Can anyone out there please explain how I can do it?
> Thanks.|||On Jul 25, 4:29 pm, "Norman Yuan" <NotR...@.NotReal.not> wrote:
Thank you Norman Yuan.
I will keep what you said in mind for future reference.
Just the other day, I too tried to install SQL Server 2005 Developer
Edition onto my XP Pro machine, which already has the SQL Server 2005
Express (Free) edition, and the installation failed at the very end--
$50 wasted buying the Developer edition. But so far I've not missed
Developer Edition anyway in my software programming (differences
between the editions found here: http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx
, with Developer being like Enterprise for the most part)
RL

Monday, March 12, 2012

InSQL 7.1 - count how many times a tag equals 1 over a specified time period query....

Need help to create a query to count how many times over a specified time the tag(s) equal the value of 1.

Thanks

Gary

Would you please provide some sample data and an example of expected results?

|||SELECT at.TagName,
'month'=month(datetime),
'YEAR'=YEAR(DATETIME),
TAGVALUE =1,
FREQ = COUNT(*)
FROM AnalogTag at, v_AnalogHistory ah
WHERE DateTime >= "2007/07/01 00:00"
AND DateTime <= "2007/07/31 00:00"
AND ah.TagName in ('PV249_STEP_NO')
AND ah.Value = 1
AND ah.TagName = at.TagName
AND wwRetrievalMode = 'DELTA'
GROUP BY at.TagName, month(DATETIME), YEAR(DATETIME)

I think I did it, using the above. I need to test a little more.

the value of the tag increments from 1 to 64, my purpose is to count the cycles of the tag.

Thanks

Gary|||

It looks like you have it correct for TagValue = 1; if you are looking to get it for all 64 different values of the tag, it would be something like:

Code Snippet

SELECT at.TagName,
'month'=month(datetime),
'YEAR'=YEAR(DATETIME),
-- TAGVALUE =1,
ah.value as TAGVALUE,
FREQ = COUNT(*)
FROM AnalogTag at, v_AnalogHistory ah
WHERE DateTime >= "2007/07/01 00:00"
AND DateTime <= "2007/07/31 00:00"
AND ah.TagName in ('PV249_STEP_NO')
-- AND ah.Value = 1
AND ah.TagName = at.TagName
AND wwRetrievalMode = 'DELTA'
GROUP BY at.TagName, ah.value, month(DATETIME), YEAR(DATETIME)

Friday, March 9, 2012

Inserts....

Hi..
I have a problem...
I have a temporary table and I'm traying to do this...
create table #tmp
( valor varchar(100),
valor1 varchar(100),
valor2 varchar(100)
)

declare @.cmd varchar(500)

select @.cmd = 'Select valor, valor2 from mytable)

insert into #tmp(valor, valor2)
exec(@.cmd)

select valor, valor2 from #tmp

but I have an error... 'Invalid object name #tmp'

why??other than a few typos everything looked good try this:

if object_id('mytable') is not null drop table mytable
if object_id('tempdb..#tmp') is not null drop table mytable

create table mytable(
valor varchar(100),
valor1 varchar(100),
valor2 varchar(100))

insert into mytable values('A','B','C')
insert into mytable values('D','E','F')
insert into mytable values('G','H','I')
insert into mytable values('J','K','L')

create table #tmp(
valor varchar(100),
valor1 varchar(100),
valor2 varchar(100))

declare @.cmd varchar(500)

select @.cmd = 'Select valor, valor2 from mytable'

insert into #tmp(valor, valor2)
exec(@.cmd)

select valor, valor2 from #tmp|||If you have this code inside of a stored proc it should work, otherwise it won't because your temporary table is local not global. (local temporary tables are visible only in the current sesion).
Try using:
CREATE TABLE ##tmp

or

CREATE TABLE tempdb..tmp

see "tempoary tables" in BOL for more details

Friday, February 24, 2012

INSERTING TEXT

Hello,
Can someone tell me how to insert text into a table containing a TEXT field?
How to update?
I would like to create a stored procedure that take a text parameter and
inserts it into a new column in my table. Then do the same stored procedure
but this time to update the TEXT field.
HELP!
YamaInsert is simple.
INSERT table_name(int_column, text_column) VALUES(1, ' ... really long text
... ')
Update is a little trickier. In the apps I write, I pull out the whole
value, let the user edit it as a whole, and write the whole value back. As
you might know, you can't append to a TEXT column (so you can't do UPDATE
table_name SET text_column += @.varcharParam), and you can't even manipulate
it locally because you can't have a local variable of type TEXT.
If you are adding things to the end of a text column, you might consider
having a separate related table with comments. That way you can track them
separately, and you don't have to worry about concatenation.
The only time I would ever update is if I have to a batch search and replace
on all rows, e.g. see http://www.aspfaq.com/2445
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Yama" <ykamyar@.grandpacificresorts.com> wrote in message
news:#4zAO0w2DHA.1532@.TK2MSFTNGP10.phx.gbl...
> Hello,
> Can someone tell me how to insert text into a table containing a TEXT
field?
> How to update?
> I would like to create a stored procedure that take a text parameter and
> inserts it into a new column in my table. Then do the same stored
procedure
> but this time to update the TEXT field.
> HELP!
> Yama
>|||Hi Aaron,
Are you sure the INSERT will work even with more than 8000 characters?
I thought you had to use the WRITETEXT command?
Yama
"Aaron Bertrand [MVP]" <aaron@.TRASHaspfaq.com> wrote in message
news:%23MPf2fy2DHA.2680@.tk2msftngp13.phx.gbl...
> Insert is simple.
> INSERT table_name(int_column, text_column) VALUES(1, ' ... really long
text
> ... ')
> Update is a little trickier. In the apps I write, I pull out the whole
> value, let the user edit it as a whole, and write the whole value back.
As
> you might know, you can't append to a TEXT column (so you can't do UPDATE
> table_name SET text_column += @.varcharParam), and you can't even
manipulate
> it locally because you can't have a local variable of type TEXT.
> If you are adding things to the end of a text column, you might consider
> having a separate related table with comments. That way you can track
them
> separately, and you don't have to worry about concatenation.
> The only time I would ever update is if I have to a batch search and
replace
> on all rows, e.g. see http://www.aspfaq.com/2445
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>
>
> "Yama" <ykamyar@.grandpacificresorts.com> wrote in message
> news:#4zAO0w2DHA.1532@.TK2MSFTNGP10.phx.gbl...
> > Hello,
> >
> > Can someone tell me how to insert text into a table containing a TEXT
> field?
> > How to update?
> >
> > I would like to create a stored procedure that take a text parameter and
> > inserts it into a new column in my table. Then do the same stored
> procedure
> > but this time to update the TEXT field.
> >
> > HELP!
> >
> > Yama
> >
> >
>|||> Are you sure the INSERT will work even with more than 8000 characters?
Yes, though it depends from where it came. Some providers / clients will
truncate because they don't know how to deal with >255 or >8000.
> I thought you had to use the WRITETEXT command?
I've never used the WRITETEXT command in production systems. www.aspfaq.com
stores articles in a TEXT column and I have no problems using INSERT /
UPDATE through a web interface. All I can suggest is that you keep your
drivers up to date (e.g. MDAC 2.8) and test your environment before taking
my word for it.
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/|||My Dear Friend,
Here is how I settled doing it.
In my ASPX web page I have four fields. A dropdown with a list of all the
letters, a checkbox for activating a letter or setting it to innactive, a
text box for the description of a letter, and another text box for the
letter with multiple line enabled. Hope you like this... :-)
--The table:
CREATE TABLE [dbo].[tblLetter] (
[LetterID] [numeric](9, 0) IDENTITY (1, 1) NOT NULL ,
[Letter] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Description] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Active] [bit] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
--The stored procedure:
CREATE PROCEDURE SaveLetter
@.Description VARCHAR(100) = '',
@.Active BIT = 1,
@.BlobLetter TEXT = '',
@.blnInsert BIT = 0,
@.LetterNumber INT = NULL,
@.blnDelete BIT = 0
AS
DECLARE @.s BINARY(16)
IF @.blnInsert = 1 AND @.blnDelete = 0
BEGIN
BEGIN TRAN
DECLARE @.ID INT
INSERT INTO tblLetter
(Description, Active, Letter) VALUES (@.Description, @.Active, @.BlobLetter)
SET @.ID = @.@.IDENTITY
SELECT @.s = TEXTPTR( Letter )
FROM tblLetter
WHERE LetterID = @.@.IDENTITY
WRITETEXT tblLetter.Letter @.s @.BlobLetter
COMMIT TRAN
END
IF @.blnInsert = 0 AND @.blnDelete = 0
BEGIN
BEGIN TRAN
UPDATE tblLetter
SET Description = @.Description , Active = @.Active
WHERE LetterID = @.LetterNumber
SELECT @.s = TEXTPTR(Letter)
FROM tblLetter
WHERE LetterID = @.LetterNumber
WRITETEXT tblLetter.Letter @.s @.BlobLetter
COMMIT TRAN
END
IF @.blnDelete = 1
BEGIN
DELETE FROM tblLetter
WHERE LetterID = @.LetterNumber
END
GO
Yama Kamyar
Senior Microsoft .NET Consultant
"Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
news:%23SAJJZ62DHA.1740@.TK2MSFTNGP09.phx.gbl...
> > Are you sure the INSERT will work even with more than 8000 characters?
> Yes, though it depends from where it came. Some providers / clients will
> truncate because they don't know how to deal with >255 or >8000.
> > I thought you had to use the WRITETEXT command?
> I've never used the WRITETEXT command in production systems.
www.aspfaq.com
> stores articles in a TEXT column and I have no problems using INSERT /
> UPDATE through a web interface. All I can suggest is that you keep your
> drivers up to date (e.g. MDAC 2.8) and test your environment before taking
> my word for it.
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>

INSERTING TEXT

Hello,
Can someone tell me how to insert text into a table containing a TEXT field?
How to update?
I would like to create a stored procedure that take a text parameter and
inserts it into a new column in my table. Then do the same stored procedure
but this time to update the TEXT field.
HELP!
YamaInsert is simple.
INSERT table_name(int_column, text_column) VALUES(1, ' ... really long text
... ')
Update is a little trickier. In the apps I write, I pull out the whole
value, let the user edit it as a whole, and write the whole value back. As
you might know, you can't append to a TEXT column (so you can't do UPDATE
table_name SET text_column += @.varcharParam), and you can't even manipulate
it locally because you can't have a local variable of type TEXT.
If you are adding things to the end of a text column, you might consider
having a separate related table with comments. That way you can track them
separately, and you don't have to worry about concatenation.
The only time I would ever update is if I have to a batch search and replace
on all rows, e.g. see http://www.aspfaq.com/2445
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Yama" <ykamyar@.grandpacificresorts.com> wrote in message
news:#4zAO0w2DHA.1532@.TK2MSFTNGP10.phx.gbl...
quote:

> Hello,
> Can someone tell me how to insert text into a table containing a TEXT

field?
quote:

> How to update?
> I would like to create a stored procedure that take a text parameter and
> inserts it into a new column in my table. Then do the same stored

procedure
quote:

> but this time to update the TEXT field.
> HELP!
> Yama
>
|||Hi Aaron,
Are you sure the INSERT will work even with more than 8000 characters?
I thought you had to use the WRITETEXT command?
Yama
"Aaron Bertrand [MVP]" <aaron@.TRASHaspfaq.com> wrote in message
news:%23MPf2fy2DHA.2680@.tk2msftngp13.phx.gbl...
quote:

> Insert is simple.
> INSERT table_name(int_column, text_column) VALUES(1, ' ... really long

text
quote:

> ... ')
> Update is a little trickier. In the apps I write, I pull out the whole
> value, let the user edit it as a whole, and write the whole value back.

As
quote:

> you might know, you can't append to a TEXT column (so you can't do UPDATE
> table_name SET text_column += @.varcharParam), and you can't even

manipulate
quote:

> it locally because you can't have a local variable of type TEXT.
> If you are adding things to the end of a text column, you might consider
> having a separate related table with comments. That way you can track

them
quote:

> separately, and you don't have to worry about concatenation.
> The only time I would ever update is if I have to a batch search and

replace
quote:

> on all rows, e.g. see http://www.aspfaq.com/2445
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>
>
> "Yama" <ykamyar@.grandpacificresorts.com> wrote in message
> news:#4zAO0w2DHA.1532@.TK2MSFTNGP10.phx.gbl...
> field?
> procedure
>
|||> Are you sure the INSERT will work even with more than 8000 characters?
Yes, though it depends from where it came. Some providers / clients will
truncate because they don't know how to deal with >255 or >8000.
quote:

> I thought you had to use the WRITETEXT command?

I've never used the WRITETEXT command in production systems. www.aspfaq.com
stores articles in a TEXT column and I have no problems using INSERT /
UPDATE through a web interface. All I can suggest is that you keep your
drivers up to date (e.g. MDAC 2.8) and test your environment before taking
my word for it.
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/|||My Dear Friend,
Here is how I settled doing it.
In my ASPX web page I have four fields. A dropdown with a list of all the
letters, a checkbox for activating a letter or setting it to innactive, a
text box for the description of a letter, and another text box for the
letter with multiple line enabled. Hope you like this... :-)
--The table:
CREATE TABLE [dbo].[tblLetter] (
[LetterID] [numeric](9, 0) IDENTITY (1, 1) NOT NULL ,
[Letter] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Description] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Active] [bit] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
--The stored procedure:
CREATE PROCEDURE SaveLetter
@.Description VARCHAR(100) = '',
@.Active BIT = 1,
@.BlobLetter TEXT = '',
@.blnInsert BIT = 0,
@.LetterNumber INT = NULL,
@.blnDelete BIT = 0
AS
DECLARE @.s BINARY(16)
IF @.blnInsert = 1 AND @.blnDelete = 0
BEGIN
BEGIN TRAN
DECLARE @.ID INT
INSERT INTO tblLetter
(Description, Active, Letter) VALUES (@.Description, @.Active, @.BlobLetter)
SET @.ID = @.@.IDENTITY
SELECT @.s = TEXTPTR( Letter )
FROM tblLetter
WHERE LetterID = @.@.IDENTITY
WRITETEXT tblLetter.Letter @.s @.BlobLetter
COMMIT TRAN
END
IF @.blnInsert = 0 AND @.blnDelete = 0
BEGIN
BEGIN TRAN
UPDATE tblLetter
SET Description = @.Description , Active = @.Active
WHERE LetterID = @.LetterNumber
SELECT @.s = TEXTPTR(Letter)
FROM tblLetter
WHERE LetterID = @.LetterNumber
WRITETEXT tblLetter.Letter @.s @.BlobLetter
COMMIT TRAN
END
IF @.blnDelete = 1
BEGIN
DELETE FROM tblLetter
WHERE LetterID = @.LetterNumber
END
GO
Yama Kamyar
Senior Microsoft .NET Consultant
"Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
news:%23SAJJZ62DHA.1740@.TK2MSFTNGP09.phx.gbl...
quote:

> Yes, though it depends from where it came. Some providers / clients will
> truncate because they don't know how to deal with >255 or >8000.
>
> I've never used the WRITETEXT command in production systems.

www.aspfaq.com
quote:

> stores articles in a TEXT column and I have no problems using INSERT /
> UPDATE through a web interface. All I can suggest is that you keep your
> drivers up to date (e.g. MDAC 2.8) and test your environment before taking
> my word for it.
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>

Sunday, February 19, 2012

Inserting records and displaying them

Before I start driving myself nuts, I'd like to make sure my approach is correct.

I want to create a simple job posting board.
I have a text boxes for company name, email, job title, and job description, and a submit button.
I created a table in my database called "JobPostings", with columns called "CoName", "CoEmail", "JobTitle", and "JobDesc"

When someone fills out the fields and clicks submit, it will insert the new records.

So,
1. Is this the correct approach so far?

2. What is the best way to display the job listings? A grid view?

3. At submit time, how can I include that day's date?

4. How can I get the records in the database to delete after 90 days?

Thanks.

1. If it did what you want, it's correct to youSmile

2. You can try SqlDataSource+GridView, see

3. You can add a datetime column (e.g. CreateDate) to the table, whose default value is getdate() so that when a new record being inserted you don't need to specify date for the column:

ALTER TABLE mytable ADD CreateDate DATETIME DEFAULT GetDate()

4. You can use such command to delete records older than 90 days:

DELETE FROM mytable WHERE DATEDIFF(d,CreateDate,GETDATE())>90

Inserting Records

Hi,

I'm using VWD 2005 Express with SQL Server 2005 Express. I've created a page "create.aspx" which will be used to insert records into a table within the database.

I've used the DetailsView control together with a SqlDataSource control on the create.aspx page.

When I run the create.aspx page it retrieves the first record in the table of the database becuase the SqlDataSource is obviously performing a"Select * from Table" command.

I don't want this to occur. I want an empty page with no records. I know I can set a WHERE clause to a value that will never return any results but I don't beleieve this is an elegant way of doing things becuase I am 'hitting the database' for no reason other than to get the table structure poplutaed into the DetailsView control.

Questions:

1. Am I using the right controls? (in particular the SqlDataSource control)

2. Is there a better way of doing this?

Your advice is most appreciated. Thank you

Try a formview with the defaultmode set to insert.

|||Motley, Thank you - that works just fine|||

Hi, I'm stuck again. Beginners bad luck.

Let's say I have a database with one table e.g. AccountsTable and this table has several fields such as:AccountID, AccountName, AccountDate, AccountActive etc.

I'm using the FormView with the DeafultMode set to Insert with:

<asp:TextBoxID="AccountDateEstablishedTextBox"runat="server"Text='<%# Bind("AccountDateEstablished") %>'></asp:TextBox>

How do I access and assign the database field?

I would like to programmatically take control. Say for example in the Sub Page_Load (not sure if this is where it should go) have something like

AccountDateEstablished = now

But I get the message saying AccountDateEstablished is not declared. Obviously, it's not referring to the same thing as what I have in mind i.e. I think it's looking for a variable in the codebehind file; when what I want is to have some logic that assigns this field in the database the value of 'now' i.e. this moment in time e.g. 21 Feb 2006.

I have the same issue with a CheckBox used for the AccountActive which is a Bit (I assume this means Boolean). All I want is for it to default to 'True' when the page loads

Another issue also closely releated. If I place a Calendar control otside the FormView then I can access the value Calendar1.SelectedDate as a vlaue in the SqlDataSource1 propoerty InsertQuery, choose AccountDateEstablished and choose from 'Control' form the Parameter Source drop down. However, if I place the Calendar control within the Formview then I cannot access this control or value.

Also, if you had a regular aspx page with a button then I could place some logic in the Click event to check for certain conditions etc. How do you do this with the prewritten FormView "Insert" Linkbutton (or Button)?

Thanks

|||

You don't assign the value to the database, the values don't get written to the database until you actually click the insert button.

It looks like you are binding the AccountDateEstablished to the AccountDateEstablishedTextbox, so if you want it to get written when you click insert, you can of course, just do:

AccountDateEstablishedTextbox.text=now

Of course, that let's the user edit the text, if that is not what you wanted, then don't bind it to a textbox, and on page load, you can do something like:

SqlDataSource1.InsertParameters("@.AccountDateEstablished").defaultvalue=now

And make the AccountDateEstablished a Parameter instead of a ControlParameter. You can also set the value during the SqlDataSource1_Inserting event.

Same for the checkbox. If you want the default to be checked, then set it as checked in page load, or if you always want it to default to checked, then just set the property of the checkbox to checked=true.

Try placing the SqlDatasouce within the formview and see if that fixes your calendar issue -- but I'm not an expert on this, I've avoided the FormView controls, etc. so far.

I would go to the code behind page, select FormView in the upper left dropdown, then see all the events I could catch in the upper right dropdown, I'm sure there is one in there that would be helpful.

|||

It looks like you are binding the AccountDateEstablished to the AccountDateEstablishedTextbox,(Yes, the system did that for me) so if you want it to get written when you click insert, you can of course, just do:

AccountDateEstablishedTextbox.text=now

Of course, that let's the user edit the text(That's fine - the easy way for now [I don't know the difference between Parameter and Control Parameter]).

Prior to submitting the post, and yet again upon your response, I have tried this in the code behind under several different combinations (upper left and right drop downs) but I keep getting the squiggly line NAME'AccountDateEstablishedTextbox' is not declared

I even triedFormView1.AccountDateEstablishedTextbox.textwith no joy i.e. I get the same message of not declared. Do I have to try each and every combination? I feel like I am missing something big here

Normally you can access a control properties in code as you mentioned withAccountDateEstablishedTextbox.text=now, but this FormView seems to be behaving differently by 'hiding the textbox control' that it created

The page has a master page, does that have any side effect?Thanks

|||

I would recommend asking that question in the data presentation controls forum. Hopefully they have a better solution for you than the only one I know of which is to do something silly like this:

CType(FormView1.FindControl("AccountDateEstablishedTextbox"),textbox).text=""

I finally realized that the FormView was wasting more of my time with sillyness like that than to just load and insert my own data so I chucked it, and did that instead.

|||

Hi Motley,

Thanks for better suggesion for inserting records. I was also face problems when i inserting hidden values. Finally I did using "e.Command.Parameters["@.EmployeeID"].Value = Profile.EmpID;" using SqlDataSource1_Inserting event.

FormView/DataList controls seems to simple when I see webcast events but it acutally time consuming at real time development. esp Inserting / Display records.

Regards,

Gopinath,

Inserting Picture in Report Builder Report

Hi everyone,

I want my users to be able to insert the logo when they create reports using report builder. Documentation tells that under Insert tab you can click on "Picture" and then browse to the location of the file and insert a picture. But I dont see "Picture" option under Insert menu. I only see 3 options "text box","Filter Description" and "Total Row Count".

Any Idea?

Thanks

Ashwini

add the text box and then insert a picture into the text box|||By Adding the text box it will not give me any options for inserting the picture. If I right click on the text box only format option is provided and there is no option for inserting picture inside the format dialog.|||

drag the Image tool from the Toolbox to location you want, the Image Wizard will come up.

If you put the Image tool directly into a table or matrix cell it is hard to control the size of it, that is why i suggested adding the text box as a container for the image.

|||

May this be related to some setting you have made during installation. On my instance of report server and report builder you can find the insert picture command under Insert menu.

Read more on sql server books online: http://msdn2.microsoft.com/en-us/library/aa337126.aspx.

By the way, reply made by dlgross seems to be related to report designer, not report builder.

|||

Yes this is the document which I was talking about in my first post. But I dont see the Picture option under Insert Menu. Is this feature newly added in SP2? or it was there before that also any idea?

Thanks

Ashwini

|||

We recently upgraded to SP2. As I can recollect the insert image feature was ther before we upgraded too.

|||

I have tried a bunch of different scenarios (open from file, open from server, etc) but haven't been able to repro this -- I keep thinking that maybe it's some sort of "rights" thing. Like, if the report is opened from an external server maybe you don't have rights to browse for an image file. I haven't hit any case where it fails yet.

The only other idea I've had is: Have you been trying repeatedly with the same test report? Does it happen with *every* report, or just the one? If just the one, how was that report originally created?

>L<

|||

No I have tried with different reports. I closed and opend the report builder tool many times to make sure if that was the issue nothing worked. And also I am working on my local machine with my local server so permission should not be a problem here I think.

Thanks

Ashwini

Inserting Picture in Report Builder Report

Hi everyone,

I want my users to be able to insert the logo when they create reports using report builder. Documentation tells that under Insert tab you can click on "Picture" and then browse to the location of the file and insert a picture. But I dont see "Picture" option under Insert menu. I only see 3 options "text box","Filter Description" and "Total Row Count".

Any Idea?

Thanks

Ashwini

add the text box and then insert a picture into the text box|||By Adding the text box it will not give me any options for inserting the picture. If I right click on the text box only format option is provided and there is no option for inserting picture inside the format dialog.|||

drag the Image tool from the Toolbox to location you want, the Image Wizard will come up.

If you put the Image tool directly into a table or matrix cell it is hard to control the size of it, that is why i suggested adding the text box as a container for the image.

|||

May this be related to some setting you have made during installation. On my instance of report server and report builder you can find the insert picture command under Insert menu.

Read more on sql server books online: http://msdn2.microsoft.com/en-us/library/aa337126.aspx.

By the way, reply made by dlgross seems to be related to report designer, not report builder.

|||

Yes this is the document which I was talking about in my first post. But I dont see the Picture option under Insert Menu. Is this feature newly added in SP2? or it was there before that also any idea?

Thanks

Ashwini

|||

We recently upgraded to SP2. As I can recollect the insert image feature was ther before we upgraded too.

|||

I have tried a bunch of different scenarios (open from file, open from server, etc) but haven't been able to repro this -- I keep thinking that maybe it's some sort of "rights" thing. Like, if the report is opened from an external server maybe you don't have rights to browse for an image file. I haven't hit any case where it fails yet.

The only other idea I've had is: Have you been trying repeatedly with the same test report? Does it happen with *every* report, or just the one? If just the one, how was that report originally created?

>L<

|||

No I have tried with different reports. I closed and opend the report builder tool many times to make sure if that was the issue nothing worked. And also I am working on my local machine with my local server so permission should not be a problem here I think.

Thanks

Ashwini