Saturday, February 25, 2012

Can I use Microsoft Access to add or modify fields in SQL Server?

I have recently upsized a medical departments database to SQL server. However, the Owner of the database wishes to add more fields using Microsoft Access. When he attempts to modify the linked table in Access, he get's the message that the table properties cannot be modified.

How can one use Access to add or modify fields in SQL server?It depends on the versions of SQL Server and Access being used, so for example Access 2000 can not modify SQL Server 2000 or SQL Server 2005 properties but Access XP/2003 should be able to.

Basically the version of access must have shipped after the version of SQL for this to work, but even then its not always the case.

Can I use Merge Replication via Developer Edition to Cluster?

I am a DBA in one IT group and we do our development work on the developer
edition of SQL Server 2005 and migrate everything to our SQL Server 2005
cluster for production.
We want to use merge replication between the Developer Edition and the
Cluster but I am being told by the DBA on the cluster that:
1. The developer edition of SQL Server does not have the same features as
the enterprise edition; that the enterprise edition is required for
implementing the SQL Cluster as this is not featured in the developers
edition.
This statement seems to conflict with what Microsoft has posted online at ...
http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx
"SQL Server 2005 Developer Edition and Evaluation Edition are not listed in
the tables. These editions have the same feature set as the Enterprise
Edition; the only difference between these editions is the licensing
policies."
2. That reporting services in the developers edition has limitations which
requires you to upgrade to the standard or enterprise edition in order to
take advantage of all the bells and whistles for this product. Our DBA sats
the developer edition is just that, a developers editio,n and which is
normally used for testing before implementing to standard or enterprise
editions of SQL Server.
3. That replicating data from a developers edition to the enterprise edition
of SQL Server Cluster is not supported by Microsoft, thus if issues arise
Micorsoft will not support this setup.
So does anyone if there's any truth to our inability to do merge replication
from the Developer Edition to the Cluster?
Thanks!
You need a new dba.
1) The developer edition supports all of the features of the Enterprise
Edition. There may be a limitation on the number of subscribers you can have
to a publication, but if there is it is not documented.
2) I am not sure about this one, but I don't think it is correct. You would
need to post to the reporting services group for more information.
3) This might be a licensing issue. The developer edition is intended for
development only. You will be able to replicate to a cluster running SQL
Server 2005 EE. When it comes to licensing issues you may have to
demonstrate licensing for auditors, but CSS will help you with problems you
may encounter while running this.
Keep in mind the developer edition is for development, not production.
Should you be replicating to production it should be a one time or
occasional occurrence as part of your development process, and not part of a
production topology.
That been said I have set up replication to development environments from a
production environment many times. I did not configure the licensing but I
am confident it was legit.
HTH
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Robert Reist" <RobertReist@.discussions.microsoft.com> wrote in message
news:0D620D0B-4432-4377-A2CD-C92C62C29EDE@.microsoft.com...
>I am a DBA in one IT group and we do our development work on the developer
> edition of SQL Server 2005 and migrate everything to our SQL Server 2005
> cluster for production.
> We want to use merge replication between the Developer Edition and the
> Cluster but I am being told by the DBA on the cluster that:
> 1. The developer edition of SQL Server does not have the same features as
> the enterprise edition; that the enterprise edition is required for
> implementing the SQL Cluster as this is not featured in the developers
> edition.
> This statement seems to conflict with what Microsoft has posted online at
> ...
> http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx
> "SQL Server 2005 Developer Edition and Evaluation Edition are not listed
> in
> the tables. These editions have the same feature set as the Enterprise
> Edition; the only difference between these editions is the licensing
> policies."
> 2. That reporting services in the developers edition has limitations which
> requires you to upgrade to the standard or enterprise edition in order to
> take advantage of all the bells and whistles for this product. Our DBA
> sats
> the developer edition is just that, a developers editio,n and which is
> normally used for testing before implementing to standard or enterprise
> editions of SQL Server.
> 3. That replicating data from a developers edition to the enterprise
> edition
> of SQL Server Cluster is not supported by Microsoft, thus if issues arise
> Micorsoft will not support this setup.
> So does anyone if there's any truth to our inability to do merge
> replication
> from the Developer Edition to the Cluster?
> Thanks!
>

Can I use MDSE instead of SQL 2000 ??

Hey guru's out there I'm attempting to run a test box with mdse instead of sql 2000 with the commerce kit..i get the following error message...when attempting to access iis: The service is installed and running on xp...

HELP

Server Error in '/CommerceVBSDK' Application.

SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.

Source Error:

Line 28: Dim products As ASPNET.StarterKit.Commerce.ProductsDB = New ASPNET.StarterKit.Commerce.ProductsDB()
Line 29:
Line 30: MyList.DataSource = products.GetProductCategories()
Line 31: MyList.DataBind()
Line 32:

Source File: C:\Program Files\ASP.NET Starter Kits\ASP.NET Commerce (VBSDK)\CommerceVBSDK\_Menu.ascx Line: 30

Stack Trace:

[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASPNET.StarterKit.Commerce.ProductsDB.GetProductCategories()
ASP._Menu_ascx.Page_Load(Object sender, EventArgs e) in C:\Program Files\ASP.NET Starter Kits\ASP.NET Commerce (VBSDK)\CommerceVBSDK\_Menu.ascx:30
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +731Try creating a blank Database with OSQL and give ASP.NET account DBO permissions in the Database before installing the Commerce Starter kit. Hope this thelps.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmsde2kwrk/html/msde2000webapp.asp

Kind regards,
Gift Peddie

Can I use Management Studio for SQL Server 2000 ?

We are using SQL Server 2000 and are going to install the first SQL Server
2005. We would like to know whether it is possible to use Management Studio
to manage all existing SQL 2000 Servers ?
ThanksYes, I use Management Studio against my SQL 2000 servers here.
There are some things in EM that are no longer or work differently in
Management Studio, but on balance you will hopefully find an improvement.
Tony.
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a SQL
Server Consultant
http://sqlserverfaq.com - free video tutorials
"John" <John@.discussions.microsoft.com> wrote in message
news:euhNCHexGHA.1888@.TK2MSFTNGP03.phx.gbl...
> We are using SQL Server 2000 and are going to install the first SQL Server
> 2005. We would like to know whether it is possible to use Management
> Studio to manage all existing SQL 2000 Servers ?
> Thanks
>|||Yes, you can use SSMS to manage SQL 2000 servers. For DTS designer support,
you'll need to install the SQL Server 2000 DTS Designer Components, which
can be downloaded from:
http://www.microsoft.com/downloads/...&displaylang=en
Hope this helps.
Dan Guzman
SQL Server MVP
"John" <John@.discussions.microsoft.com> wrote in message
news:euhNCHexGHA.1888@.TK2MSFTNGP03.phx.gbl...
> We are using SQL Server 2000 and are going to install the first SQL Server
> 2005. We would like to know whether it is possible to use Management
> Studio to manage all existing SQL 2000 Servers ?
> Thanks
>|||Dear Dan and Tony,
Thank you for your advice.
John
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:%23QM2zQexGHA.428@.TK2MSFTNGP03.phx.gbl...
> Yes, you can use SSMS to manage SQL 2000 servers. For DTS designer
> support, you'll need to install the SQL Server 2000 DTS Designer
> Components, which can be downloaded from:
> http://www.microsoft.com/downloads/...&displaylang=en
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "John" <John@.discussions.microsoft.com> wrote in message
> news:euhNCHexGHA.1888@.TK2MSFTNGP03.phx.gbl...
>

Can I use Management Studio for SQL Server 2000 ?

We are using SQL Server 2000 and are going to install the first SQL Server
2005. We would like to know whether it is possible to use Management Studio
to manage all existing SQL 2000 Servers ?
ThanksYes, I use Management Studio against my SQL 2000 servers here.
There are some things in EM that are no longer or work differently in
Management Studio, but on balance you will hopefully find an improvement.
Tony.
--
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a SQL
Server Consultant
http://sqlserverfaq.com - free video tutorials
"John" <John@.discussions.microsoft.com> wrote in message
news:euhNCHexGHA.1888@.TK2MSFTNGP03.phx.gbl...
> We are using SQL Server 2000 and are going to install the first SQL Server
> 2005. We would like to know whether it is possible to use Management
> Studio to manage all existing SQL 2000 Servers ?
> Thanks
>|||Yes, you can use SSMS to manage SQL 2000 servers. For DTS designer support,
you'll need to install the SQL Server 2000 DTS Designer Components, which
can be downloaded from:
http://www.microsoft.com/downloads/details.aspx?familyid=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&displaylang=en
--
Hope this helps.
Dan Guzman
SQL Server MVP
"John" <John@.discussions.microsoft.com> wrote in message
news:euhNCHexGHA.1888@.TK2MSFTNGP03.phx.gbl...
> We are using SQL Server 2000 and are going to install the first SQL Server
> 2005. We would like to know whether it is possible to use Management
> Studio to manage all existing SQL 2000 Servers ?
> Thanks
>|||Dear Dan and Tony,
Thank you for your advice.
John
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:%23QM2zQexGHA.428@.TK2MSFTNGP03.phx.gbl...
> Yes, you can use SSMS to manage SQL 2000 servers. For DTS designer
> support, you'll need to install the SQL Server 2000 DTS Designer
> Components, which can be downloaded from:
> http://www.microsoft.com/downloads/details.aspx?familyid=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&displaylang=en
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "John" <John@.discussions.microsoft.com> wrote in message
> news:euhNCHexGHA.1888@.TK2MSFTNGP03.phx.gbl...
>> We are using SQL Server 2000 and are going to install the first SQL
>> Server 2005. We would like to know whether it is possible to use
>> Management Studio to manage all existing SQL 2000 Servers ?
>> Thanks
>

Can I use keyword Like with a Parameter

Should be simple. I'm writing a report to find employees by last name.

I want the user to key in at least a few characters of the last name and the report will search for all last names that are like that.

I know in TSQL it would go:

Last_name like 'Jones%'

But how do I set up a parameter in Reporting Services

I've tried:

last_name like =@.name%

Any ideas?

Thanks,

Jim

Any ideas? Can the Keyword "Like" be used to find similar occurences of a user entered parameter...|||Within the dataset query you can declare a variable that references the parameter with the text then append the necessary % to the end. So the reference would look something like...

DECLARE @.some_variable NVARCHAR(40)
SET @.some_variable = @.parameter_field_text + '%'

You can then use this...

SELECT *
FROM some_view
WHERE NameField LIKE @.some_variable|||

You would probably need to use dynamic sql and expression.

="Select * from table1 where last_name like '" + @.name + "%'"

Or use a stored procedure and perform the like statement within it.

cheers,

Andrew

Can I use KB 303459 to increase FT performance in 2005 and 2008?

I notice that KB 303459 (http://support.microsoft.com/kb/303459/en-us)
increase the FT performance in SQL Server 2000 and previous versions. The
increase is accomplished only by a registry setting which is very easy to
achive. I am wondering if I can use this article in SQL Server 2005 or SQL
Server 2008 to improve the performance as well.
Many thanks!
Felix Jiang
No, consult this white paper for performance tweaks in SQL 2005!
http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/ftslesld.mspx
http://www.zetainteractive.com - Shift Happens!
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Felix_Jiang" <FelixJiang@.discussions.microsoft.com> wrote in message
news:53C15A1D-1D9C-4DD8-94EC-F95C814D2F9D@.microsoft.com...
>I notice that KB 303459 (http://support.microsoft.com/kb/303459/en-us)
> increase the FT performance in SQL Server 2000 and previous versions. The
> increase is accomplished only by a registry setting which is very easy to
> achive. I am wondering if I can use this article in SQL Server 2005 or SQL
> Server 2008 to improve the performance as well.
> Many thanks!
> Felix Jiang

Can I use integrated security in an ODBC connection string without using a DSN?

Can I use integrated security in an ODBC connection string without using a
DSN?
If so, what would the syntax be for SQL Server and Oracle (if supported by
Oracle)?
TonyTrusted connection:
"Driver={SQL Server};Server=Aron1;Database=pubs;Trust
ed_Connection=yes;
"
from http://www.connectionstrings.com/ (really good source for
connectionstrings)
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Tony" <tonyng2@.spacecommand.net> schrieb im Newsbeitrag
news:O4upNWsbFHA.3492@.TK2MSFTNGP14.phx.gbl...
> Can I use integrated security in an ODBC connection string without using a
> DSN?
> If so, what would the syntax be for SQL Server and Oracle (if supported by
> Oracle)?
> Tony
>|||Thanks...
Do you know of a way to connect using integrated security with Oracle?
Tony
"Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote in
message news:Onf$jAtbFHA.2936@.tk2msftngp13.phx.gbl...
> Trusted connection:
> "Driver={SQL Server};Server=Aron1;Database=pubs;Trust
ed_Connection=ye
s;"
> from http://www.connectionstrings.com/ (really good source for
> connectionstrings)
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "Tony" <tonyng2@.spacecommand.net> schrieb im Newsbeitrag
> news:O4upNWsbFHA.3492@.TK2MSFTNGP14.phx.gbl...
>|||YOu have to set a parameter in the SQLNet.Ora
http://www.windowsitpro.com/Windows...2280/42280.html
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Tony" <tonyng2@.spacecommand.net> schrieb im Newsbeitrag
news:Oq36BPwbFHA.1044@.TK2MSFTNGP10.phx.gbl...
> Thanks...
> Do you know of a way to connect using integrated security with Oracle?
> Tony
> "Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote
> in message news:Onf$jAtbFHA.2936@.tk2msftngp13.phx.gbl...
>

Can I use integrated security in an ODBC connection string without using a DSN?

Can I use integrated security in an ODBC connection string without using a
DSN?
If so, what would the syntax be for SQL Server and Oracle (if supported by
Oracle)?
Tony
Trusted connection:
"Driver={SQL Server};Server=Aron1;Database=pubs;Trusted_Connect ion=yes;"
from http://www.connectionstrings.com/ (really good source for
connectionstrings)
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
"Tony" <tonyng2@.spacecommand.net> schrieb im Newsbeitrag
news:O4upNWsbFHA.3492@.TK2MSFTNGP14.phx.gbl...
> Can I use integrated security in an ODBC connection string without using a
> DSN?
> If so, what would the syntax be for SQL Server and Oracle (if supported by
> Oracle)?
> Tony
>
|||Thanks...
Do you know of a way to connect using integrated security with Oracle?
Tony
"Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote in
message news:Onf$jAtbFHA.2936@.tk2msftngp13.phx.gbl...
> Trusted connection:
> "Driver={SQL Server};Server=Aron1;Database=pubs;Trusted_Connect ion=yes;"
> from http://www.connectionstrings.com/ (really good source for
> connectionstrings)
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "Tony" <tonyng2@.spacecommand.net> schrieb im Newsbeitrag
> news:O4upNWsbFHA.3492@.TK2MSFTNGP14.phx.gbl...
>
|||YOu have to set a parameter in the SQLNet.Ora
http://www.windowsitpro.com/Windows/...280/42280.html
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
"Tony" <tonyng2@.spacecommand.net> schrieb im Newsbeitrag
news:Oq36BPwbFHA.1044@.TK2MSFTNGP10.phx.gbl...
> Thanks...
> Do you know of a way to connect using integrated security with Oracle?
> Tony
> "Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote
> in message news:Onf$jAtbFHA.2936@.tk2msftngp13.phx.gbl...
>

Can I use IIF statement in the RS query?

I tried to insert this line of code to the Column in the query design but it
doesn't work. Similar command works in MS-ACCESS.
IIf('[Policy Received?]=No', DateDiff('y', tblFileInfo.EffDate, GETDATE), 0)
Can someone help, thanks in advance.You can put this kind of formula in the textbox that displays the data. The
query design is limited to the back-end functionality, and Access has some
extra VB capabilities most databases don't support. But the reporting front
end does support this.
Cheers,
--
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"LV" <LV@.discussions.microsoft.com> wrote in message
news:3210CAF1-91B7-401F-B1EF-E6B1D29161FC@.microsoft.com...
>I tried to insert this line of code to the Column in the query design but
>it
> doesn't work. Similar command works in MS-ACCESS.
> IIf('[Policy Received?]=No', DateDiff('y', tblFileInfo.EffDate, GETDATE),
> 0)
> Can someone help, thanks in advance.|||In addition to what Jeff says. What database are you going against? If it is
against Access MDB then you might be able to use the generic query window
(versus the graphical). This is basically passthrough window. It depends on
how the Access OLEDB provider handles it. If it is against SQL Server data
then this will definitely not work since it is not SQL Server SQL format. If
going against SQL Server then you can always test out your SQL using the
Query Analyzer.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Jeff A. Stucker" <jeff@.mobilize.net> wrote in message
news:eyBkf%2391EHA.1300@.TK2MSFTNGP14.phx.gbl...
> You can put this kind of formula in the textbox that displays the data.
The
> query design is limited to the back-end functionality, and Access has some
> extra VB capabilities most databases don't support. But the reporting
front
> end does support this.
> Cheers,
> --
> '(' Jeff A. Stucker
> \
> Business Intelligence
> www.criadvantage.com
> ---
> "LV" <LV@.discussions.microsoft.com> wrote in message
> news:3210CAF1-91B7-401F-B1EF-E6B1D29161FC@.microsoft.com...
> >I tried to insert this line of code to the Column in the query design but
> >it
> > doesn't work. Similar command works in MS-ACCESS.
> >
> > IIf('[Policy Received?]=No', DateDiff('y', tblFileInfo.EffDate,
GETDATE),
> > 0)
> >
> > Can someone help, thanks in advance.
>|||Thank you,
Yes I am using Access data, as you suggested I will try the textbox method.
"Jeff A. Stucker" wrote:
> You can put this kind of formula in the textbox that displays the data. The
> query design is limited to the back-end functionality, and Access has some
> extra VB capabilities most databases don't support. But the reporting front
> end does support this.
> Cheers,
> --
> '(' Jeff A. Stucker
> \
> Business Intelligence
> www.criadvantage.com
> ---
> "LV" <LV@.discussions.microsoft.com> wrote in message
> news:3210CAF1-91B7-401F-B1EF-E6B1D29161FC@.microsoft.com...
> >I tried to insert this line of code to the Column in the query design but
> >it
> > doesn't work. Similar command works in MS-ACCESS.
> >
> > IIf('[Policy Received?]=No', DateDiff('y', tblFileInfo.EffDate, GETDATE),
> > 0)
> >
> > Can someone help, thanks in advance.
>
>|||Thank you,
I did try the generic SQL but did not get the correct results somehow it
return just he true side of the IIF statement. Here is how I get around my
problem, I created the query with the IIF statemet in Access, on RS report I
connect to the query and it works. I don't know if this is the correct way
to do it but for now at least I can get it to work.
"Bruce L-C [MVP]" wrote:
> In addition to what Jeff says. What database are you going against? If it is
> against Access MDB then you might be able to use the generic query window
> (versus the graphical). This is basically passthrough window. It depends on
> how the Access OLEDB provider handles it. If it is against SQL Server data
> then this will definitely not work since it is not SQL Server SQL format. If
> going against SQL Server then you can always test out your SQL using the
> Query Analyzer.
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
>
> "Jeff A. Stucker" <jeff@.mobilize.net> wrote in message
> news:eyBkf%2391EHA.1300@.TK2MSFTNGP14.phx.gbl...
> > You can put this kind of formula in the textbox that displays the data.
> The
> > query design is limited to the back-end functionality, and Access has some
> > extra VB capabilities most databases don't support. But the reporting
> front
> > end does support this.
> >
> > Cheers,
> >
> > --
> > '(' Jeff A. Stucker
> > \
> >
> > Business Intelligence
> > www.criadvantage.com
> > ---
> > "LV" <LV@.discussions.microsoft.com> wrote in message
> > news:3210CAF1-91B7-401F-B1EF-E6B1D29161FC@.microsoft.com...
> > >I tried to insert this line of code to the Column in the query design but
> > >it
> > > doesn't work. Similar command works in MS-ACCESS.
> > >
> > > IIf('[Policy Received?]=No', DateDiff('y', tblFileInfo.EffDate,
> GETDATE),
> > > 0)
> > >
> > > Can someone help, thanks in advance.
> >
> >
>
>

Can I use if statement in a table valued function?

hi,

I am using a function in sql server 2005 like this:

...... myfunction(... @.FlagOn int)

.......

begin

return

(

if(@.FlagOn = 1)

select * from.......

else

select * form....

)

end

But it keeps complaining there is some syntax error around if. What is it?

Thanks.

No. Table valued function won’t allow this. Because it might cause more than one schema definition for the table valued function, which is not possible in the database.

If it is a filter then you can attach the additional condition on the where clause. If the flag is used to fetch different columns or different table create new function for each flag.

If the final schema is same (same number of columns and identical datatype for both the flags), use table valued function (not inline table valued function).

Code Snippet

Create function getvalues(@.flag as int)

Returns @.result table (id int, name varchar(100))

As

Begin

If @.flag=1

Insert into @.result

Select Top 10 id, name from sysobjects

Else

Insert into @.result

Select Top 10 id,name from syscolumns

return;

End

Go

Select * from getvalues(1)

go

Select * from getvalues(0)

|||

Thanks lot, it works great.

Another thing is, can I create index on table @.result?

Coz I am thinking something like this:

select * from getvalues(1) as s where s.ID > 100

If it has index on ID, it might be faster.

|||

Maximum you can add Primary Key/Unique key on the table variable. If your values are unique then you can go for it.

@.result table (id int primary key, name varchar(100))

Can I Use If Condition In View

HiiiALL..
I AM CREATING A VIEW AND USE IN THIS IF AND ELSE CONDITION.
THIS SYNTAX IS NOT WORKING PROPERLY..CAN USE OR NOT??No, you can not use IF condition in a view.
There are so many other ways to do it.

Thank you.|||

Quote:

Originally Posted by iburyak

No, you can not use IF condition in a view.
There are so many other ways to do it.

Thank you.


thank u sir for reply
u say that there is many ways.
so sir what is the other way..|||1. You can create a table function.
2. You can return result of a stored procedure.
3. You can use where condition on existing view.
4. You can use Case in select statements of a view which is in many cases is almost the same as IF ELSE.
5. You can create different views and use them depend on a conditions like.
Create view View_StoredProcs
AS
select name from sysobjects where type like 'p'

Create view View_Tables
AS
select name from sysobjects where type like 'u'

and more....|||Hi iburyak,

I've used the case statement and it is working as expected here.

Thanks for the excellent explanation.|||

Quote:

Originally Posted by leniel

Hi iburyak,

I've used the case statement and it is working as expected here.

Thanks for the excellent explanation.


You are welcome.
For generic question I had a generic answer.
I am glad you were able to get some info out of it... :)
Good Luck.

Can I use Hyperlinks in a SQL Server CE database?

Is it possible to store a hyperlink in a SQL Server Compact Edition Database?

Specifically, I would like to have the link point to an .jpg file stored in a folder on the computer.

Thanks!The "hyperlink" field type is not supported, by you can store text in a SQL CE database, both the Hyperlink description and the file path (in 2 nvarchar fields)

Can i use Group by in the row filter when i doing merge replication?

Can i use Group by in the row filter when i doing merge replication?
Cheers
nick
no, but depending on what you are trying to do you might be able to
encapsulate it in a UDF.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
"Nick" <fsheng@.ebreathe.co.nz> wrote in message
news:udKeCo$BFHA.3708@.TK2MSFTNGP14.phx.gbl...
> Can i use Group by in the row filter when i doing merge replication?
> Cheers
> nick
>
>
>

Can I use Forms Authentication with reporting services?

Hello, In my application I can configure if the user need to use forms or activde direcory, there may be customers that dont have active directory so Must make a login form, the question is how can I integrate forms authentication with reporting services?Yes, see the link below for a sample: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql2k/html/ufairs.asp

Thanks
Tudor

Can I use Enterprise Manager to manage MSSQL 2005 express?

Can I use the regular Enterprise Manager to manage MSSQL 2005 express or do
I have to use the Express Manager?
SQL Server 2000 Enterprise Manager does not have support for new SQL Server
2005 features. Express Manager is being replaced with a new Express version
of the SQL Server Management Studio tool introduced in SQL Server 2005. You
can get a Customer Technical Preview version of Management Studio Express
from here:
http://www.microsoft.com/downloads/d...displaylang=en
Alan Brewer [MSFT]
Content Architect, SQL Server Documentation Team
SQL Server Developer Center: http://msdn.microsoft.com/sql
SQL Server TechCenter: http://technet.microsoft.com/sql/
This posting is provided "AS IS" with no warranties, and confers no rights.

Can I use else if... like this?

hi,
In SQL Server, does it have this:
if...
else if ...
else if....
else....

It seems I have to do it like this:
if..
else...
begin
if ....
else
begin
if......
end
end

i think you can do it this one works well

USE pubsIF (SELECT AVG(price) FROM titles WHERE type = 'mod_cook') < $15
BEGIN
PRINT 'The following titles are excellent mod_cook books:'
PRINT ' '
SELECT SUBSTRING(title, 1, 35) AS Title
FROM titles
WHERE type = 'mod_cook'
END
ELSE
IF (SELECT AVG(price) FROM titles WHERE type = 'mod_cook') > $15
BEGIN
PRINT 'The following titles are expensive mod_cook books:'
PRINT ' '
SELECT SUBSTRING(title, 1, 35) AS Title
FROM titles
WHERE type = 'mod_cook'
END
ELSE
IF (SELECT AVG(price) FROM titles WHERE type = 'mod_cook') > $50
BEGIN
PRINT 'The following titles are more expensive mod_cook books:'
PRINT ' '
SELECT SUBSTRING(title, 1, 35) AS Title
FROM titles
WHERE type = 'mod_cook'
END

Can I use dynamic SQL in a stored procedure to call another stored

Hi,
I am having one stored procedure named SP1 which is having one input and one
output parameter as follows
CREATE PROCEDURE dbo.SP1
@.xmldoc TEXT
,@.FLAG_EXEC VARCHAR(5)
AS
BEGIN
...
END
I have write another stored procedure named SP2 which is creating a dynamic
SQL statement like
CREATE PROCEDURE dbo.SP2
AS
BEGIN
DECLARE @.CURR_PROC_NAME VARCHAR(125)
DECLARE @.STR_XML_AS_VARCHAR VARCHAR(125)
DECLARE @.STR_RET_QRY_MN VARCHAR(125)
DECLARE @.STR_EXECUTE_QRY VARCHAR(4000)
SET @.STR_EXECUTE_QRY = 'exec ' + @.CURR_PROC_NAME + ''''+
@.STR_XML_AS_VARCHAR + ''' , @.STR_RET_QRY_MN OUTPUT ,@.FLAG_EXEC = ''FALSE'' '
print @.STR_EXECUTE_QRY
EXEC (@.STR_EXECUTE_QRY)
END
but it always says to declare @.STR_RETURN_STRING variable. Can I do like
above? If yes then how? If no then why?
With thanx in advance,Hi Rajendra,
this does not work because each EXEC is running in it's own process.
That means in fact that proc2 does not know anything about the variables
you have declared in proc1.
You should handle it as follows:
Proc2 (Sub-Proc) writes the ReturnValue into a table
Proc2 (Calling Proc) reads after the run of Proc2 the value from the table
Another way is to work with "sp_executesql". See BOL for details...
HTH ;-)
Gru, Uwe Ricken
MCP for SQL Server 2000 Database Implementation
GNS GmbH, Frankfurt am Main
http://www.gns-online.de
http://www.memberadmin.de
http://www.conferenceadmin.de
________________________________________
____________
dbdev: http://www.dbdev.org
APP: http://www.AccessProfiPool.de
FAQ: http://www.donkarl.com/AccessFAQ.htm|||Rajendra (Rajendra@.discussions.microsoft.com) writes:
> I have write another stored procedure named SP2 which is creating a
> dynamic SQL statement like
> CREATE PROCEDURE dbo.SP2
> AS
> BEGIN
> DECLARE @.CURR_PROC_NAME VARCHAR(125)
> DECLARE @.STR_XML_AS_VARCHAR VARCHAR(125)
> DECLARE @.STR_RET_QRY_MN VARCHAR(125)
> DECLARE @.STR_EXECUTE_QRY VARCHAR(4000)
> SET @.STR_EXECUTE_QRY = 'exec ' + @.CURR_PROC_NAME + ''''+
> @.STR_XML_AS_VARCHAR + ''' , @.STR_RET_QRY_MN OUTPUT ,@.FLAG_EXEC = ''FALSE''
'
> print @.STR_EXECUTE_QRY
> EXEC (@.STR_EXECUTE_QRY)
> END
> but it always says to declare @.STR_RETURN_STRING variable. Can I do like
> above? If yes then how? If no then why?
You are making it too complicated. Just say:
EXEC @.CURR_PROC_NAME @.STR_XML_AS_VARCHAR, STR_RET_QRY_MN OUTPUT,
@.FLAG_EXEC = 'FALSE'
This will execute the procedure of which the name is in @.CURR_PROC_NAME.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Can I use DSN for OLE DB connection?

Hello all,

I am relatively new to SQL and Database. Your help is greatly appreciated! Thanks in advance!

Recently, I joined a company that uses MS SQL Server. Our team, which is located in Toronto, has been maintaining and updating a database. The following is some information on the connection string that we are currently using.

Dim con As ADODB.Connection

Set con = New ADODB.Connection
con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog = CBA; Data Source=PROD.CORP.COMPANY.COM"

Just last week, I was informed that people in the New York Office requires access to the database. What they want to do, essentially, is to have the ability to use the same spreadsheet that retrieves data from our database. My concern is that the computers in the New York Office might not be under the same server. The "static" Data Source stated in the connection string might not work. I was advise to switch over to ODBC connection so that I can specify a System DSN name to point to a specific server. This will allow me to change the "path" that the DSN is pointed to, without going through the code and change every Data Source name, is this true?

I've been reading up on ODBC and OLE DB. The impression I got is that OLE DB is superior to ODBC. It just doesn't make sense for me to "downgrade", is it? Please advise on what I should do so that people in both the Toronto and the NY office will have access to the database. In addition, is there a way for me to simulate a "remote access" scenario so taht I can be sure the new connection is working as it should be?

Thank you so much for your help! I really appreciate your time and effort in helping me to solve this issue.

Best regards,

William

For DSNs in specific, you can use the OLE DB provider for ODBC and use IPersistFile::Load to load the dsn. Details available at

http://msdn.microsoft.com/library/en-us/oledb/htm/odbcproviderinitialization_properties_and_kag_files.asp?frame=true

For the SQLOLEDB provider, you can use the UDL files instead of DSN files to allow managing connections to data sources.

Details at http://msdn.microsoft.com/library/en-us/oledb/htm/datalinkapioverview.asp?frame=true

Suroor

Can I use dimension in SQL SERVER 2005?

I hope to pass a dimension such as int A[5] to a stored procedure

A[0]=10

A[1]=20

...

Can I do that in sql server 2005? if so , please give me a sample, thanks!

I dont think you can do that in SQL yet. You could pass a delimited string and parse it over in your stored proc.

Can I use date control for parameter in RS2000?

Can I use date control for parameter in RS2000?
--
Seeing your smile always brings me joyRS 2000 does not come with a date picker for parameters. To do this you
would have to have your own web pages and then use either URL integration or
web services to integrate with RS. RS 2005 does have a date picker control.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Macro" <Jihong.Liu@.gmail.com> wrote in message
news:5FA06B84-339D-4ED6-93FA-EE6F3E4CDCB9@.microsoft.com...
> Can I use date control for parameter in RS2000?
> --
> Seeing your smile always brings me joy|||I use date type report parameters but convert them to strings when
mapping to stored procedure parameters. E.g.,
CStr(Parameters!BeginDate.value).
Bruce L-C [MVP] wrote:
> RS 2000 does not come with a date picker for parameters. To do this you
> would have to have your own web pages and then use either URL integration or
> web services to integrate with RS. RS 2005 does have a date picker control.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "Macro" <Jihong.Liu@.gmail.com> wrote in message
> news:5FA06B84-339D-4ED6-93FA-EE6F3E4CDCB9@.microsoft.com...
> > Can I use date control for parameter in RS2000?
> >
> > --
> > Seeing your smile always brings me joy

Can I use data drive subscription on a remote sql standard version

I would like to upgrade our report server to sql 2000 enterprise
edition to be able to use the DD subscriptions.. if I do do upgrade the
server, will I be able to connect to a sql server on another box with
the standard version and continue to use DD subscriptions on that
remote server.
or is there another way to get around this issue by way of stored
procedures.. thanks.What specifically do you mean by "continue to use DD susbscriptions no that
remote server"? Do you mean the remote server is the source of data that
drives the DD subscription? In that case, yes.
-Tim
"Joaquin" <joaquin.pineda@.gmail.com> wrote in message
news:1147897141.934976.263120@.38g2000cwa.googlegroups.com...
>I would like to upgrade our report server to sql 2000 enterprise
> edition to be able to use the DD subscriptions.. if I do do upgrade the
> server, will I be able to connect to a sql server on another box with
> the standard version and continue to use DD subscriptions on that
> remote server.
> or is there another way to get around this issue by way of stored
> procedures.. thanks.
>|||Tim Dot NoSpam wrote:
> What specifically do you mean by "continue to use DD susbscriptions no that
> remote server"? Do you mean the remote server is the source of data that
> drives the DD subscription? In that case, yes.
>
Tim, you got it, that's what I wanted to know. also, do you know if its
possible to simulate dd subscriptions, let say by way of stored proc?
on standard version of sql. thanks.

Can I use Custom UI for executing Package in C#?

Hi

I've a doubt. I don't know whether it is possible or not.

I've a very less knowledge in DTS packages.

When I execute a package in C#. it is displaying predefined GUI for showing process.

Can I've my own UI when executing DTS.

Thanks in advance.

Could you clarify what you mean by "When I execute a package in C#" and whether the question is about DTS 2000 or SSIS. This forum is about SSIS, BTW.|||

Thanks for the reply Michael

I'm using SSIS

I'm putting the C# code here


public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Package package;
ConnectionManager ConMgr;

Package p;
private void Form1_Load(object sender, EventArgs e)
{
string pkg ="Package.dtsx";

Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
p = app.LoadPackage(pkg, null);

}

private void button1_Click(object sender, EventArgs e)
{
if(p!=null)

p.Execute();

}
}

When I click on Button ie) p.Execute(); is invoked I need my own UI to see the processing . Is it possible.

Thank u

|||Of course - you need to implement event sink interface (IDTSEvents) and/or logging sink interface (IDTSLogging), and call package.Execute(...) version that takes these interfaces (pass null for all other arguments). You'll get the information about the package progress and can show the UI similar (or completely different if you choose) to the one DtExecUI shows (DtExecUI uses the same interfaces).|||

Thanks michael

It is useful

and can I know abt DtExecUI for what it is useful for?.]

|||Well, it executes the packages :)

Some people use command line and some people like to use GUI to execute packages. We provide DTEXEC and DTEXECUI for each group appropriately.|||

Thank u Michael .

Thanks for ur support to know these.

And finally one , can u provide some resource to learn , how to create custom UI. and executing package.etc

|||

Hi

I've one more doubt.

Executing package is a single threaded or multi threaded?

Can I catch the names of the currently transfering table when Executing package?

Thanks in advance.

|||Execution is multithreaded, you'll need to gather information you need from the event and pass it to the UI thread, and probably call package.Execute() on a different thread too to avoid locking up the UI.

There are many events and log information, see Books Online for details. Creative use of this information joined with the package information (e.g. transform properties) may give you most of the information you need.

I don't have any sample, sorry.|||

Thanks alot Michael.

Can I use CASE expression in AND condition?

Hello:
Is it possible to useCASE expression inAND condition? i.e.
-------------
CREATE PROC spBlah
(
@.id INT,
@.val INT
)
AS
SELECT *
FROM aTable
WHERE tableID = @.id
AND
(
CASE @.val WHEN 1 THEN otherCol = someValue END
CASE @.val WHEN 2 THEN otherCol != someOtherVlaue END
)
--------------AND is a Boolean Operator and is also a JOIN condition operator used by databases like SQL Server for extra JOIN search conditions. I don't think it can be used with a CASE statement. Try the link below for CASE statement code. Hope this helps.
http://www.craigsmullins.com/ssu_0899.htm|||For your case, you might try to build the query dynamically and store the query into a SQL variable. Then use the exec method to execute the query. I don't think you can do the way you are heading. Build only the variable part and then append to the fixed part. Hope I am not confusing you...
declare @.tmp varchar(300)
if(@.val = 1)
set @.tmp = 'otherCol = someValue'
else
set @.tmp = 'otherCol != someOtherVlaue'
set @.tmp = 'SELECT * FROM aTable WHERE tableID = @.id AND ' + @.tmp
exec(@.tmp)
Thanks

Can I use business objects as a data source?

We have decided to use business objects in our new application, which seems to be working well, since they can be used as a binding source for grids, etc.

I am trying to evaluate whether SSIS is a practical solution for our ETL requirements. The problem is, I can't find any examples or references, or even the slightest hint that anyone is using them with business objects. Any attempts to search yield a ton of results which are based on a commercial product called "Business Objects" rather than the design pattern.

It is currently a requirement of our development team that all data access must be done via business objects, rather than communicating directly with the database.

Can anyone provide some more information (besides just suggesting I write a custom connection manager)? Is there anyone who has actually made SSIS work with business objects?

Thanks, Richard

What is a "business object"?|||I don't know what kind of information you're looking for. Yes, it can be done. Yes, you'll have to write custom components to talk to the business objects instead of the database. I've done it for Reporting Services as a custom data extension (source) and it wasn't a bunch of fun. SSIS I think would be even less. Biggest downside I can think of off-hand is that you won't be able to bulk load into the database (think row-by-row), which is going to be really painful in an ETL scenario. I've never heard of an ETL process that wasn't allowed to access the database directly.
|||I'd concur with Jay's assessment. I've done some similar work in the past. Business objects are usually not very efficient for accessing large amounts of data. If your data movement is going to be on an individual row basis, I'm not sure SSIS is the best option for implementing it.|||

We are a 3PL, so in our case, ETL is more along the lines of importing batches of orders and exporting batches of shipping confirmations from and to a variety of data formats. Row-by-row is not an issue.

It would be nice to find a working example of how to do this prior to investing a bunch of time into SSIS.

|||This sounds more like BizTalk than SSIS. It isn't your business objects that I'd be concerned about in SSIS, it's the "variety of data formats". SSIS wants to move 10,000+ rows per second between well-defined sources and destinations and do a bunch of transformations along the way. BizTalk wants to route transactions between different systems and talk different formats to each one.
|||

BizTalk has a price tag. We already have SSIS. Everything I've read to date on it indicates that it is something we should be able to use to meet our needs. I am not questioning whether SSIS is the best choice. I would like to know if anyone has used it successfully with business objects, and if so, can they provide some examples, or other helpful information.

Thanks, Richard.

|||What will your business objects be constructed as? COM objects, web services, .NET assemblies? That has an impact on how easy they are to interface with.|||

SSIS Evaluator wrote:

BizTalk has a price tag. We already have SSIS. Everything I've read to date on it indicates that it is something we should be able to use to meet our needs. I am not questioning whether SSIS is the best choice. I would like to know if anyone has used it successfully with business objects, and if so, can they provide some examples, or other helpful information.

Thanks, Richard.

Can I reiterate Phil's question (above)? What exactly are these "business objects"?

-Jamie

|||

It's a generic term for objects that represent business entities and the rules associated with those entities. So you might have a Customer business object, with all the attributes that a customer has, and methods to represent any operations that can be performed on the customer. Usually, these provide a layer of abstraction between the database and the user interface. Business objects know where their data is stored for persistence, and user interfaces request information from the business objects rather than accessing the database directly. Changes in the data from the UI are also handled through the business object. Data validation, enforcement of business rules, etc, are all handled in the business object.

In the OP's case, evidently they have made an architectural decision that all data access has to go through these business objects. As has been stated, it is possible to do this with SSIS. The degree of complexity depends in large part on how the business objects are implemented. If this is being looked at a method to handle importing or exporting data from business objects to an external database, it might work OK, assuming performance is not the major concern. If it is for business object to business object communication, I really think the OP would be better off investigating other tools.

Can I use BCP to append data to an existing sql server table? Than

Can I use BCP to append data to an existing sql server table? ThanYes
Mike John
"Min" <Min@.discussions.microsoft.com> wrote in message
news:26E8CAB3-C61A-4004-974F-BAA42CA6FE1E@.microsoft.com...
>

Can I use BCP to append data to an existing sql server table? Than

Can I use BCP to append data to an existing sql server table? ThanYes
Mike John
"Min" <Min@.discussions.microsoft.com> wrote in message
news:26E8CAB3-C61A-4004-974F-BAA42CA6FE1E@.microsoft.com...
>

Can I use BCP to append data to an existing sql server table? Than

Can I use BCP to append data to an existing sql server table? ThanYes
Mike John
"Min" <Min@.discussions.microsoft.com> wrote in message
news:26E8CAB3-C61A-4004-974F-BAA42CA6FE1E@.microsoft.com...
>|||Thanks for your reply. Can you please give me an example? Thanks again.
"Mike John" wrote:
> Yes
> Mike John
> "Min" <Min@.discussions.microsoft.com> wrote in message
> news:26E8CAB3-C61A-4004-974F-BAA42CA6FE1E@.microsoft.com...
> >
>
>|||Oops, I forgot BCP is by default appending since we have been using
overwrting the data for so long...
"Min" wrote:
> Thanks for your reply. Can you please give me an example? Thanks again.
> "Mike John" wrote:
> > Yes
> >
> > Mike John
> >
> > "Min" <Min@.discussions.microsoft.com> wrote in message
> > news:26E8CAB3-C61A-4004-974F-BAA42CA6FE1E@.microsoft.com...
> > >
> >
> >
> >

can I use an attribute in a calculation?

i have an instrument dimension. the instrument dimension has a conversion ratio attribute (i.e. each instrument has a conversion ratio). the conversion ratio attribute is not interesting for analysis in itself, but is often used in calculations.

I want to say somehting like this:

for all instruments, show me sum of [measures].[Price] * ~ CONVERSION RATIO OF THAT INSTRUMENT ~

this actually works ok at the detail level. however, when I start rolling up instruments into say, sectors, then i get a type mismatch error saying that teh "All" member cannot be converted to type double.

In general, is it valid to use a non-measure group dimension attribute to perform a calculation? If not, should any attribute that might participate in a calculation be created as a measure (even though it has no real analysis value by itself). Or should I do the

"Fact * Looked Up Attribute"-type calculation in the DSV and create a new Fact called something like [Price X Conv Ratio]?

The first of these queries generates the error you mention above. I believe the second handles the logic in the manner you are wanting. I haven't had a lot of time to look at this, so I would highly recommend you independtly verify the results of this logic (or the version you implement) to make sure the values are correct. Also, I used a SUM function to aggregate the values in the calculated member. There are a number of functions available to you. In this situation, AVG may be more appropriate.

Thanks,
Bryan

Code Snippet

withmember Measures.[x] as

[Measures].[Reseller Sales Amount]/[Product].[List Price].CurrentMember

select

{[x],[Reseller Sales Amount]} on 0

from [Adventure Works]

;

withmember Measures.[x] as

SUM(

[Product].[List Price].[List Price].Members,

([Product].[List Price].CurrentMember, [Measures].[Reseller Sales Amount])/

[Product].[List Price].CurrentMember.MemberValue

), format="#,#"

select

{[x],[Reseller Sales Amount]} on 0

from [Adventure Works]

;

Can I use AMO from .net 2003?

I'm working with SQL server 2005 beta 2 from C# 2003
I want to know if I can somehow work with amo ?

I would really appreciate any kind of sugestionAMO (Microsoft.AnalysisServices.dll) is built and works with .net framework 2.0, so you will not be able to use it with Visual Studio 2003 (that uses .net framework 1.1).

SQL Setup 2005 install .net framework 2.0, so you can build AMO applications from command line with csc.exe. Or use Visual Studio 2005 Beta 2 (http://lab.msdn.microsoft.com/vs2005/).

Adrian.

Can I use ALTER LOGIN in a stored procedure?

Can the ALTER USER statement be used (without a hack like using EXEC) in a stored procedure? I know that the sp_password system stored procedure can not be. Additionally, it is being deprecated anyway. I guess what is boggling me about my attempts so far relate to the errors I am getting due to the user being specified not being in quotes in the syntax. All of the searching I have done so far have come up lame so far; the only examples I have found about it were in scripts that create other scripts for transferring users and other administrative tasks that would be run from the query window, but not from an application. To be complete as possible, here is an example of a script the returns errors:

ALTER PROC [dbo].[lbxChangePassword]
(
@.loginid nvarchar(180),
@.oldpassword nvarchar(40),
@.newpassword nvarchar(40)
) AS BEGIN

IF @.oldpassword = (SELECT password FROM contacts WHERE loginid = @.loginid)
BEGIN
BEGIN TRANSACTION
UPDATE contacts
SET password = @.newpassword
WHERE loginid = @.loginid

ALTER LOGIN @.loginid WITH PASSWORD=@.newpassword OLD_PASSWORD=@.oldpassword
END
ELSE
BEGIN
RAISERROR(N'The password you entered does not match your current password.', 16, 1)
RETURN
END

IF @.@.ERROR <> 0
BEGIN
RAISERROR(N'There was an error creating your new password.', 16, 1)
RETURN
END

COMMIT TRANSACTION

END

************
This returns:

Msg 102, Level 15, State 1, Procedure lbxChangePassword, Line 15
Incorrect syntax near '@.loginid'.
Msg 319, Level 15, State 1, Procedure lbxChangePassword, Line 15
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
************

If ALTER LOGIN isn't how to change the password, then please tell me what the correct practice of changing a password is. I want to use the CURRENT_USER keyword in my queries and want I can't finish setting that up until I have this resolved because users will need to change their own passwords through the application I am developing.

I guess you have to put that in dynamic sql to execute:

DECLARE @.SQLStrng NVARCHAR(500)
SET @.SQLString = 'ALTER LOGIN ' + @.loginid + ' WITH PASSWORD= '' + @.newpassword + '' OLD_PASSWORD= '' + @.oldpassword + '''
EXEC(SQLString )

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||

Yes, the DDL does not accept variables. If you build the string dynamically, use quotename() around the variable names to get them quoted properly:

DECLARE @.SQLStrng NVARCHAR(500)
SET @.SQLString = 'ALTER LOGIN ' + quotename(@.loginid) + ' WITH PASSWORD= ' + quotename(@.newpassword, '''') + ' OLD_PASSWORD= ' + quotename(@.oldpassword, '''')
EXEC(SQLString )

Thanks
Laurentiu

|||

I'll try this, but I was hoping that there would be a way to do this without using a "hack".

Am I not approaching this the right way? The user will be logging into a PHP application and I need for them to be able to change their password. Would you recommend a stored procedure to accomplish this like the ones we've been writing about, or is there a best practice for this. I mean, otherwise how can one administer database users from a web app and still use SQL Server's security model? I don't understand Microsoft's reasoning in this architecture.

|||

Writing a stored procedure to accomplish this is OK. If you don't like to build the dynamic SQL and execute it with EXEC, you might prefer using sp_executesql instead: http://msdn2.microsoft.com/en-US/library/ms175170(SQL.90).aspx.

Thanks
Laurentiu

|||

Well, I read a post by a SQL Server MVP that said that another way to do this is to specify the old/new password in a connection string to the SQL Server Native Client. e.g.:

"Provider=SQLNCLI;Data Source=MyServer;User ID=MyLogin;Old Password=oldpassword;Password=password"

But I don't think PHP is friendly to connection strings though; I tried fiddling with ODBC connections in PHP with no luck. Has anyone heard anything about this?

|||

Try posting on SQL Server Data Access for more details on the connection string idea. I think this connection string is probably meant to be used when a login password is expired; it is not the regular way of changing a login password. If you're looking at all possible ways of changing a login password, you should also check the SQL Server SMO/DMO forum - you could write a CLR procedure to perform this action (see .NET Framework inside SQL Server for questions on using CLR inside SQL Server).

Thanks
Laurentiu

|||

I'm just a curious person :-) Thanks. Good Ideas.

-Ryan

Can I Use ADOMD or AMO In ASP.NET 2.0

Hi~

I know some function can be used in debug mode,like MsgBox()...,in ASP.NET 2.0.

But I don't know that Can ADOMD or AMO be used in ASP.NET 2.0.

Could someone tell me?

thanks~

Server: SQL Server 2005

OS: Windows 2003

Yes you can use both ADOMD and AMO from ASP.NET. The main "trick" is to get the code executing as a user that has the approriate rights to access the required SSAS objects. Setting up your application pool up to run under a domain account that is in appropriate SSAS roles is one way of getting this to work.

Can I use Access as a server?

Is it possible to use Access as a server? If not, is there any other way to read
the database that Access created please?

Gary

Hi Garry,

This link says it is possible to use Access as a Server which works well with the size limit of 1GB but then it obviously requires expert coding to make it function as a server.

Thanks

Subhash Subramanyam

Can I use a Web Service Method as a Data Source

Can I use a Web Service Method as a Data Source in Report Creation.
Any help will be greatly appreciated.
Vishwanathan RamanYes you can definitely do that. It does involve a bit of work though. You'll
need to built a custom data extension (there's a sample on creating a data
extension for an ADO.NET dataset on MSDN) that will call the web service and
provide the report with the results of the call.
"Vishwanathan Raman" <VishwanathanRaman@.discussions.microsoft.com> wrote in
message news:C7DF2501-D37D-44B0-A1CE-F027741942B4@.microsoft.com...
> Can I use a Web Service Method as a Data Source in Report Creation.
> Any help will be greatly appreciated.
> Vishwanathan Raman
>

Can I use a variable to hold the target table name.

We need to pull from a table that is named tablename_mmddyy and populate a table with the same format tablename_mmddyy. The date will be different every month so I want to be able to build the tablenames every month. Is there a way to do this in SSIS? Thank you.Yes, using expressions in your variables, you can do what you want.

Create a variable and then for its properties, set EvaluateAsExpression to True and then build your expression accordingly in the Expression box.

Then in your OLE DB source/destination, you can use that variable as the table. Just know that you'll want to probably set DelayValidation to True on your connection managers when you do this.

There are plenty of examples in this forum if you search for them on how to build expressions, if you need.|||I found the option for this under Data Access Mode but we need to do the same thing for the database name which will be in a similar format e.g. databasename_mmddyy and the source db name will change every month.|||Same thing. You can use expressions on your connection managers to dynamically create the current connection string.|||The same principals can be applied to a connection manager (i.e. database name of database server). You can use an expression to build the connection string from a variable in the properties window of the connection manager.|||Any examples of this?|||

agentf1 wrote:

Any examples of this?

In the ConnectionString expression box for a connection manager. Also it can't hurt to set DelayValidation to True.

"Data Source=" + @.[User::YourDatabaseNameVariable] +";Initial Catalog=Report;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;"|||What goes in the database name field? I am assuming that it gets overridden by the expression.|||

agentf1 wrote:

What goes in the database name field? I am assuming that it gets overridden by the expression.

The ConnectionString will override any other parameters.|||

agentf1 wrote:

Any examples of this?

http://search.live.com/results.aspx?FORM=QBJK&q1=macro%3Ajamiet.ssis&q=expressions

-JT

|||This seems to be changing both of my OLE DB Connections. Is there a way one can be static and the other updated by the variable? It also appears that Data Source controls the server and Catalog is the database name.|||

agentf1 wrote:

This seems to be changing both of my OLE DB Connections. Is there a way one can be static and the other updated by the variable?

That's impossible (unless one of us has misunderstood). An expression on the ConnectionString property of a connection manager only changes that connection manager.

agentf1 wrote:

It also appears that Data Source controls the server and Catalog is the database name.

Correct.

-Jamie

|||

Jamie Thomson wrote:

agentf1 wrote:

This seems to be changing both of my OLE DB Connections. Is there a way one can be static and the other updated by the variable?

That's impossible (unless one of us has misunderstood). An expression on the ConnectionString property of a connection manager only changes that connection manager.

agentf1 wrote:

It also appears that Data Source controls the server and Catalog is the database name.

Correct.

-Jamie

My bad, I had the expression on both connections. I am OK, thanks for all the help, worked beautifully.

Can I use a UDF in an IF statement?

Is it possible to use a user defined function in an IF statement? The UDF returns a scalar value. Like:
IF dbo.DoSomething (@.x)

The only way I can see to call a UDF is with
SELECT @.y = dbo.DoSomething (@.x)


Thank you!

YES but you have to compare its result with something or your function should return bit or integer value IF dbo.DoSomething (@.x)=1

Can I use a table variable in sp_executesql for output

Can I use a table variable to gain output using the sp_executesql procedure?
Example:
Normally I might have something like:
DECLARE @.max varchar(9),@.sExec nvarchar(200)
SELECT @.sExec=N'SELECT @.max=(SELECT MAX(ID) FROM Parts)'
EXEC sp_executesql @.sExec, N'@.max varchar(9) OUTPUT', @.max OUTPUT
print @.max
--I'm doing something wrong... what?
--Instead can it be written to work like this?
DECLARE @.tmp TABLE(@.max varchar(9)null)
DECLARE @.sExec nvarchar(200)
SELECT @.sExec=N'INSERT INTO @.tmp =(SELECT Convert(varchar(9),ID) FROM Parts)'
N'@.tmp TABLE(@.max varchar(9)null) OUTPUT', @.tmp OUTPUT
SELECT Max(ID) FROM @.tmp
Regards,
Jamie
No but you can create a temp table before you call the sp_executesql and
access it from inside the dynamic sql. Those rows that you insert inside
the dynamic sql will still be there after the sp_executesql batch is done.
Andrew J. Kelly SQL MVP
"thejamie" <thejamie@.discussions.microsoft.com> wrote in message
news:99D6CE2F-9252-4AB9-A690-8CF00420926C@.microsoft.com...
> Can I use a table variable to gain output using the sp_executesql
> procedure?
> Example:
> Normally I might have something like:
> DECLARE @.max varchar(9),@.sExec nvarchar(200)
> SELECT @.sExec=N'SELECT @.max=(SELECT MAX(ID) FROM Parts)'
> EXEC sp_executesql @.sExec, N'@.max varchar(9) OUTPUT', @.max OUTPUT
> print @.max
> --I'm doing something wrong... what?
> --Instead can it be written to work like this?
> DECLARE @.tmp TABLE(@.max varchar(9)null)
> DECLARE @.sExec nvarchar(200)
> SELECT @.sExec=N'INSERT INTO @.tmp =(SELECT Convert(varchar(9),ID) FROM
> Parts)'
> N'@.tmp TABLE(@.max varchar(9)null) OUTPUT', @.tmp OUTPUT
> SELECT Max(ID) FROM @.tmp
> Regards,
> Jamie
|||Andrew,
Thanks for replying.
I am trying to get percentages of a single table for weighting.
If I understand right, then this should work for my first 60 percent of the
table.
DECLARE @.PercA varchar(2)
SELECT @.PercA='60'
DECLARE @.ITEMZ1 TABLE(item_no varchar(30))
SELECT @.SQL=N'(INSERT INTO @.ITEMZ1 SELECT TOP '+@.A+N' PERCENT L.item_no FROM
iminvloc_sql L INNER JOIN imitmidx_sql N ON L.loc = N.loc AND L.item_no =
N.item_no ORDER BY L.avg_cost * L.usage_ytd DESC)'
EXEC sp_executesql @.SQL, N'@.ITEMZ1 TABLE(item_no varchar(30)) OUTPUT',
@.ITEMZ1 OUTPUT
SELECT * FROM @.ITEMZ1
I'm missing something. Is it obvious?
Jamie
"Andrew J. Kelly" wrote:

> No but you can create a temp table before you call the sp_executesql and
> access it from inside the dynamic sql. Those rows that you insert inside
> the dynamic sql will still be there after the sp_executesql batch is done.
> --
> Andrew J. Kelly SQL MVP
>
> "thejamie" <thejamie@.discussions.microsoft.com> wrote in message
> news:99D6CE2F-9252-4AB9-A690-8CF00420926C@.microsoft.com...
>
>
|||I found something similar - says it works in YUKON only.
http://www.c-sharpcorner.com/Longhor...ordInYukon.asp
This is what I really want. Is there a way to do this pre-YUKON?
DECLARE @.n AS int
SET @.n = 60
SELECT TOP(@.n)
L.item_no FROM iminvloc_sql L INNER JOIN imitmidx_sql N ON L.loc = N.loc
AND L.item_no = N.item_no
ORDER BY L.avg_cost * L.usage_ytd DESC
"Andrew J. Kelly" wrote:

> No but you can create a temp table before you call the sp_executesql and
> access it from inside the dynamic sql. Those rows that you insert inside
> the dynamic sql will still be there after the sp_executesql batch is done.
> --
> Andrew J. Kelly SQL MVP
>
> "thejamie" <thejamie@.discussions.microsoft.com> wrote in message
> news:99D6CE2F-9252-4AB9-A690-8CF00420926C@.microsoft.com...
>
>
|||Suppose the tmptable needed to be created from a string variable fed into the
stored procedure:
The last line below does not work, but follows the same logic. Can a temp
table be created from an EXEC (@.SQL) statement?
DECLARE @.SQL nvarchar(4000),@.BeginPercent tinyint,@.EndPercent
tinyint,@.SQLLength int,@.FieldList varchar(4000),@.SQLTmpTbl
nvarchar(4000),@.ComputedField varchar(128)
SELECT @.SQL=N'SELECT
L.item_no,N.item_desc_1,N.item_desc_2,L.usage_ytd, L.avg_cost,L.inv_class,L.loc,L.prod_cat
FROM iminvloc_sql L INNER JOIN imitmidx_sql N ON L.loc = N.loc AND L.item_no
= N.item_no ORDER BY L.avg_cost * L.usage_ytd DESC'
SELECT @.ComputedField=N'L.usage_ytd * L.avg_cost'
DECLARE @.SQLSelect nvarchar(4000),@.SQLFROM nvarchar(4000)
SELECT @.SQLSelect=dbo.instr(@.SQL,'FROM')
SELECT @.SQLFROM=REPLACE(@.SQL,@.SQLSelect,'')
SELECT @.FieldList=LTRIM(RTRIM(REPLACE(@.SQLSelect,'SELECT' ,'')))
SELECT @.FieldList=REPLACE(@.FieldList,',',' varchar(255),')
SELECT @.FieldList=@.FieldList+' nvarchar(255)'
SELECT @.SQLTmpTbl=N'DECLARE @.tmp TABLE('+@.Fieldlist+N')'
Print REPLACE(@.SQLTmpTbl,'.','_')
exec sp_executesql @.SQLTmpTbl
"Andrew J. Kelly" wrote:

> No but you can create a temp table before you call the sp_executesql and
> access it from inside the dynamic sql. Those rows that you insert inside
> the dynamic sql will still be there after the sp_executesql batch is done.
> --
> Andrew J. Kelly SQL MVP
>
|||First of all that is a table variable and not a temp table. But in either
case it will not work as you expect. The scoping of variables and temp
tables that are created inside dynamic sql are limited to that execution
only. Once they are done the code outside of that dynamic batch will not
see those objects. Only if you create a temp table (not a table var)
outside of the dynamic sql batch will it be usable in the batch and then
again after the batch. Have a look at these:
http://www.aspfaq.com/show.asp?id=2248 Arrays & Lists
http://www.sommarskog.se/dynamic_sql.html Dynamic SQL
http://www.users.drew.edu/skass/sql/...leProc.sql.txt List to
Table script
http://www.support.microsoft.com/?id=262499 Using OutPut Params &
sp_executeSql
Andrew J. Kelly SQL MVP
"thejamie" <thejamie@.discussions.microsoft.com> wrote in message
news:BE8B9EC0-7CD2-4E71-BA09-C966895456D8@.microsoft.com...[vbcol=seagreen]
> Suppose the tmptable needed to be created from a string variable fed into
> the
> stored procedure:
> The last line below does not work, but follows the same logic. Can a
> temp
> table be created from an EXEC (@.SQL) statement?
> DECLARE @.SQL nvarchar(4000),@.BeginPercent tinyint,@.EndPercent
> tinyint,@.SQLLength int,@.FieldList varchar(4000),@.SQLTmpTbl
> nvarchar(4000),@.ComputedField varchar(128)
> SELECT @.SQL=N'SELECT
> L.item_no,N.item_desc_1,N.item_desc_2,L.usage_ytd, L.avg_cost,L.inv_class,L.loc,L.prod_cat
> FROM iminvloc_sql L INNER JOIN imitmidx_sql N ON L.loc = N.loc AND
> L.item_no
> = N.item_no ORDER BY L.avg_cost * L.usage_ytd DESC'
> SELECT @.ComputedField=N'L.usage_ytd * L.avg_cost'
> DECLARE @.SQLSelect nvarchar(4000),@.SQLFROM nvarchar(4000)
> SELECT @.SQLSelect=dbo.instr(@.SQL,'FROM')
> SELECT @.SQLFROM=REPLACE(@.SQL,@.SQLSelect,'')
> SELECT @.FieldList=LTRIM(RTRIM(REPLACE(@.SQLSelect,'SELECT' ,'')))
> SELECT @.FieldList=REPLACE(@.FieldList,',',' varchar(255),')
> SELECT @.FieldList=@.FieldList+' nvarchar(255)'
> SELECT @.SQLTmpTbl=N'DECLARE @.tmp TABLE('+@.Fieldlist+N')'
> Print REPLACE(@.SQLTmpTbl,'.','_')
> exec sp_executesql @.SQLTmpTbl
>
> "Andrew J. Kelly" wrote:
|||That worked quite well. Thank you Andrew
"Andrew J. Kelly" wrote:

> First of all that is a table variable and not a temp table. But in either
> case it will not work as you expect. The scoping of variables and temp
> tables that are created inside dynamic sql are limited to that execution
> only. Once they are done the code outside of that dynamic batch will not
> see those objects. Only if you create a temp table (not a table var)
> outside of the dynamic sql batch will it be usable in the batch and then
> again after the batch. Have a look at these:
>
> http://www.aspfaq.com/show.asp?id=2248 Arrays & Lists
> http://www.sommarskog.se/dynamic_sql.html Dynamic SQL
> http://www.users.drew.edu/skass/sql/...leProc.sql.txt List to
> Table script
> http://www.support.microsoft.com/?id=262499 Using OutPut Params &
> sp_executeSql
>
> --
> Andrew J. Kelly SQL MVP
>
> "thejamie" <thejamie@.discussions.microsoft.com> wrote in message
> news:BE8B9EC0-7CD2-4E71-BA09-C966895456D8@.microsoft.com...
>
>

Can I use a table variable in sp_executesql for output

Can I use a table variable to gain output using the sp_executesql procedure?
Example:
Normally I might have something like:
DECLARE @.max varchar(9),@.sExec nvarchar(200)
SELECT @.sExec=N'SELECT @.max=(SELECT MAX(ID) FROM Parts)'
EXEC sp_executesql @.sExec, N'@.max varchar(9) OUTPUT', @.max OUTPUT
print @.max
--I'm doing something wrong... what?
--Instead can it be written to work like this?
DECLARE @.tmp TABLE(@.max varchar(9)null)
DECLARE @.sExec nvarchar(200)
SELECT @.sExec=N'INSERT INTO @.tmp =(SELECT Convert(varchar(9),ID) FROM Parts)
'
N'@.tmp TABLE(@.max varchar(9)null) OUTPUT', @.tmp OUTPUT
SELECT Max(ID) FROM @.tmp
Regards,
JamieNo but you can create a temp table before you call the sp_executesql and
access it from inside the dynamic sql. Those rows that you insert inside
the dynamic sql will still be there after the sp_executesql batch is done.
Andrew J. Kelly SQL MVP
"thejamie" <thejamie@.discussions.microsoft.com> wrote in message
news:99D6CE2F-9252-4AB9-A690-8CF00420926C@.microsoft.com...
> Can I use a table variable to gain output using the sp_executesql
> procedure?
> Example:
> Normally I might have something like:
> DECLARE @.max varchar(9),@.sExec nvarchar(200)
> SELECT @.sExec=N'SELECT @.max=(SELECT MAX(ID) FROM Parts)'
> EXEC sp_executesql @.sExec, N'@.max varchar(9) OUTPUT', @.max OUTPUT
> print @.max
> --I'm doing something wrong... what?
> --Instead can it be written to work like this?
> DECLARE @.tmp TABLE(@.max varchar(9)null)
> DECLARE @.sExec nvarchar(200)
> SELECT @.sExec=N'INSERT INTO @.tmp =(SELECT Convert(varchar(9),ID) FROM
> Parts)'
> N'@.tmp TABLE(@.max varchar(9)null) OUTPUT', @.tmp OUTPUT
> SELECT Max(ID) FROM @.tmp
> Regards,
> Jamie|||Andrew,
Thanks for replying.
I am trying to get percentages of a single table for weighting.
If I understand right, then this should work for my first 60 percent of the
table.
DECLARE @.PercA varchar(2)
SELECT @.PercA='60'
DECLARE @.ITEMZ1 TABLE(item_no varchar(30))
SELECT @.SQL=N'(INSERT INTO @.ITEMZ1 SELECT TOP '+@.A+N' PERCENT L.item_no FROM
iminvloc_sql L INNER JOIN imitmidx_sql N ON L.loc = N.loc AND L.item_no =
N.item_no ORDER BY L.avg_cost * L.usage_ytd DESC)'
EXEC sp_executesql @.SQL, N'@.ITEMZ1 TABLE(item_no varchar(30)) OUTPUT',
@.ITEMZ1 OUTPUT
SELECT * FROM @.ITEMZ1
I'm missing something. Is it obvious?
Jamie
"Andrew J. Kelly" wrote:

> No but you can create a temp table before you call the sp_executesql and
> access it from inside the dynamic sql. Those rows that you insert inside
> the dynamic sql will still be there after the sp_executesql batch is done.
> --
> Andrew J. Kelly SQL MVP
>
> "thejamie" <thejamie@.discussions.microsoft.com> wrote in message
> news:99D6CE2F-9252-4AB9-A690-8CF00420926C@.microsoft.com...
>
>|||I found something similar - says it works in YUKON only.
http://www.c-sharpcorner.com/Longho...wordInYukon.asp
This is what I really want. Is there a way to do this pre-YUKON?
DECLARE @.n AS int
SET @.n = 60
SELECT TOP(@.n)
L.item_no FROM iminvloc_sql L INNER JOIN imitmidx_sql N ON L.loc = N.loc
AND L.item_no = N.item_no
ORDER BY L.avg_cost * L.usage_ytd DESC
"Andrew J. Kelly" wrote:

> No but you can create a temp table before you call the sp_executesql and
> access it from inside the dynamic sql. Those rows that you insert inside
> the dynamic sql will still be there after the sp_executesql batch is done.
> --
> Andrew J. Kelly SQL MVP
>
> "thejamie" <thejamie@.discussions.microsoft.com> wrote in message
> news:99D6CE2F-9252-4AB9-A690-8CF00420926C@.microsoft.com...
>
>|||Suppose the tmptable needed to be created from a string variable fed into th
e
stored procedure:
The last line below does not work, but follows the same logic. Can a temp
table be created from an EXEC (@.SQL) statement?
DECLARE @.SQL nvarchar(4000),@.BeginPercent tinyint,@.EndPercent
tinyint,@.SQLLength int,@.FieldList varchar(4000),@.SQLTmpTbl
nvarchar(4000),@.ComputedField varchar(128)
SELECT @.SQL=N'SELECT
L.item_no,N.item_desc_1,N.item_desc_2,L.usage_ytd,L.avg_cost,L.inv_class,L.l
oc,L.prod_cat
FROM iminvloc_sql L INNER JOIN imitmidx_sql N ON L.loc = N.loc AND L.item_no
= N.item_no ORDER BY L.avg_cost * L.usage_ytd DESC'
SELECT @.ComputedField=N'L.usage_ytd * L.avg_cost'
DECLARE @.SQLSelect nvarchar(4000),@.SQLFROM nvarchar(4000)
SELECT @.SQLSelect=dbo.instr(@.SQL,'FROM')
SELECT @.SQLFROM=REPLACE(@.SQL,@.SQLSelect,'')
SELECT @.FieldList=LTRIM(RTRIM(REPLACE(@.SQLSelec
t,'SELECT','')))
SELECT @.FieldList=REPLACE(@.FieldList,',',' varchar(255),')
SELECT @.FieldList=@.FieldList+' nvarchar(255)'
SELECT @.SQLTmpTbl=N'DECLARE @.tmp TABLE('+@.Fieldlist+N')'
Print REPLACE(@.SQLTmpTbl,'.','_')
exec sp_executesql @.SQLTmpTbl
"Andrew J. Kelly" wrote:

> No but you can create a temp table before you call the sp_executesql and
> access it from inside the dynamic sql. Those rows that you insert inside
> the dynamic sql will still be there after the sp_executesql batch is done.
> --
> Andrew J. Kelly SQL MVP
>|||First of all that is a table variable and not a temp table. But in either
case it will not work as you expect. The scoping of variables and temp
tables that are created inside dynamic sql are limited to that execution
only. Once they are done the code outside of that dynamic batch will not
see those objects. Only if you create a temp table (not a table var)
outside of the dynamic sql batch will it be usable in the batch and then
again after the batch. Have a look at these:
http://www.aspfaq.com/show.asp?id=2248 Arrays & Lists
http://www.sommarskog.se/dynamic_sql.html Dynamic SQL
http://www.users.drew.edu/skass/sql...bleProc.sql.txt List to
Table script
http://www.support.microsoft.com/?id=262499 Using OutPut Params &
sp_executeSql
Andrew J. Kelly SQL MVP
"thejamie" <thejamie@.discussions.microsoft.com> wrote in message
news:BE8B9EC0-7CD2-4E71-BA09-C966895456D8@.microsoft.com...[vbcol=seagreen]
> Suppose the tmptable needed to be created from a string variable fed into
> the
> stored procedure:
> The last line below does not work, but follows the same logic. Can a
> temp
> table be created from an EXEC (@.SQL) statement?
> DECLARE @.SQL nvarchar(4000),@.BeginPercent tinyint,@.EndPercent
> tinyint,@.SQLLength int,@.FieldList varchar(4000),@.SQLTmpTbl
> nvarchar(4000),@.ComputedField varchar(128)
> SELECT @.SQL=N'SELECT
> L.item_no,N.item_desc_1,N.item_desc_2,L.usage_ytd,L.avg_cost,L.inv_class,L
.loc,L.prod_cat
> FROM iminvloc_sql L INNER JOIN imitmidx_sql N ON L.loc = N.loc AND
> L.item_no
> = N.item_no ORDER BY L.avg_cost * L.usage_ytd DESC'
> SELECT @.ComputedField=N'L.usage_ytd * L.avg_cost'
> DECLARE @.SQLSelect nvarchar(4000),@.SQLFROM nvarchar(4000)
> SELECT @.SQLSelect=dbo.instr(@.SQL,'FROM')
> SELECT @.SQLFROM=REPLACE(@.SQL,@.SQLSelect,'')
> SELECT @.FieldList=LTRIM(RTRIM(REPLACE(@.SQLSelec
t,'SELECT','')))
> SELECT @.FieldList=REPLACE(@.FieldList,',',' varchar(255),')
> SELECT @.FieldList=@.FieldList+' nvarchar(255)'
> SELECT @.SQLTmpTbl=N'DECLARE @.tmp TABLE('+@.Fieldlist+N')'
> Print REPLACE(@.SQLTmpTbl,'.','_')
> exec sp_executesql @.SQLTmpTbl
>
> "Andrew J. Kelly" wrote:
>|||That worked quite well. Thank you Andrew
"Andrew J. Kelly" wrote:

> First of all that is a table variable and not a temp table. But in either
> case it will not work as you expect. The scoping of variables and temp
> tables that are created inside dynamic sql are limited to that execution
> only. Once they are done the code outside of that dynamic batch will not
> see those objects. Only if you create a temp table (not a table var)
> outside of the dynamic sql batch will it be usable in the batch and then
> again after the batch. Have a look at these:
>
> http://www.aspfaq.com/show.asp?id=2248 Arrays & Lists
> http://www.sommarskog.se/dynamic_sql.html Dynamic SQL
> http://www.users.drew.edu/skass/sql...bleProc.sql.txt List to
> Table script
> http://www.support.microsoft.com/?id=262499 Using OutPut Params &
> sp_executeSql
>
> --
> Andrew J. Kelly SQL MVP
>
> "thejamie" <thejamie@.discussions.microsoft.com> wrote in message
> news:BE8B9EC0-7CD2-4E71-BA09-C966895456D8@.microsoft.com...
>
>

Can I use a stored procedure for INSERT in SqlDataSource?

Hello,

I have created a web page with a FormView that allows me to add and edit data in my database. I configured the SqlDataSource control and it populated the SELECT, INSERT, UPDATE and DELETE statements. I've created a stored procedure to do the INSERT and return to new identity value. My question is this: Can I configure the control to use this stored procedure? If so, how? Or do I have to write some code for one of the event handlers (inserting, updating?)

Any help would be appreciated.

-brian

Yes you can. Not seeing your code makes it difficult to diagnose, but it sounds like you have the SqlDataSource partially set up. Make sure you also have the insertcommand attribute set to your new stored procedure and the insertcommandtype set to "StoredProcedure". The InsertParameters should also be set to include any input parameters that are not explicitly bound within the FormView.InsertItemTemplate.

From here, you need to make sure the FormView is in insert mode, your InsertItemTemplate is properly set up, and you have an insert button with the CommandName attribute properly set to "Insert".

Once you click that button, the FormView.ItemInserting event will fire, then the SqlDataSource.Inserting event will fire.

Assuming you have all of your stored procedure input parameters properly set up within your ASPX page, your stored procedure should run, and you can pick up your return parameter from the SqlDataSource.Inserted event.

Hope this helps.

can i use a store procedure as default value for a column?

Is it possible to use a stored procedure to fill the default value of a column when i'm building the db?

i mean if i can use a stored procedure for the "colum property": "default value or bnding"

if yes how can i do it?

No, you won't be able to specify a stored procedure in your table definition as a default value for a column. Your best bet for this is to set up a trigger (either AFTER or INSTEAD OF) to enforce the default value.

|||

You can, however, use a scalar user-defined function as the default value. So if you can convert the sproc to a UDF or call it from one, you're good to go.

Don

Can I use a published report as a datasource for other reports?

Hi,

I have a data table called STOCKPE which holds stock valuation information at the close of business each day. I wish to use reporting services to extract the data in this table on a daily basis and keep a daily history on the report server. I know I can do this - this isn't my problem.

When I have the history of this table on the report server, can the data that the reports on the report server hold be used as a datasource for another report?

I'm no expert in reporting services, so if this is possible, or if there's a better way of doing it, please use small words and short sentences. No offence intended to all the very well educated SQLRS wizards out there, it's just that I'm not one of them and your answer will be lost on me if you use a lot of abreviations and acronyms.

Thanks,

Chris

Hi,

I guess you are takling about Snaphots in SQL Server RS. Snapshots are dedicted to one Report (actually its a snapshot of the report). AFAIK there is no way to base reports on other reports snapshot data.

HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

|||

Hi Jens,

I had a feeling this was the case but y'never know so I thought I'd ask all the same.

Thanks for your response, much appreciated.

Chris

Can I use a DataSet with 2 Tables in Reporting Services

I have created a DataSet with Table[0] and Table[1] in a stored proc. When I
create a new dataset using the stroed proc, I can only see Table[0]. Is it
possible to create a report using a DataSet with 2 tables such as this?
Thanks...Greyhound,
This is not possible. You have two choices;
1) Create two datasets in your report and split your stored proc up.
2) Union the results for each table into a single table and add a filter
field to filter the results in the report.
AK Code Rat
"Greyhound" wrote:
> I have created a DataSet with Table[0] and Table[1] in a stored proc. When I
> create a new dataset using the stroed proc, I can only see Table[0]. Is it
> possible to create a report using a DataSet with 2 tables such as this?
> Thanks...

Can I use a data field returned from my report as part of the URL address?

I am familiar with the navigation hyperlink action of "Jump to URL" but I cant get it to use the data returned in the report as part of the URL address. When I enter the Url into the expression editor: ="http://internal.company.address/sys1/sys2/caseEdit.pl?case="&"Fields!CaseID.Value" it opens an explorer window but it echos the address and tries to use the text 'Fields!CaseID.Value' instead of the data returned in that field.

Can this be done?

="http://internal.company.address/sys1/sys2/caseEdit.pl?case=" & Fields!CaseID.Value

|||Thanks, this answers my question. Seems so simply once I see the answer.

Can I use a 'Conditional CHECK' constraint ?

Hi SQL Gurus,
Using Sql2000, I have a table to maintain stock availibility, the
requirement is qty_in_orders must be <= qty_on_hand, so I use CHECK
constraint like below :
CREATE TABLE StockAvailibility
(prod_code CHAR(5) NOT NULL PRIMARY KEY,
qty_on_hand INTEGER NOT NULL,
qty_in_orders INTEGER NOT NULL,
CHECK (qty_on_hand >= qty_in_orders));
The problem is : user need more flexible approach, they want to decide at
initial implementation / runtime where they need this constraint, there is a
parameter table to store this setting.
CREATE TABLE App_Parameter
(Check_Stock bit);
The above CHECK constraint should only be run if App_Parameter.Check_Stock = 1.
How can I do this ?
TIA,
KristYou could possibly use a UDF which returns 0 or 1 and which checks against the other table. Watch
out, though, that if you don't refer to the column in the check constraint, then the optimizer might
not deem is necessary to validate the CHECK constraint. This can happen when you have CHECK
constraint which uses UDF can work against other tables. I don't think that it will be a problem in
your case, though. You could have something like:
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"tristant" <krislioe@.cbn.net.id> wrote in message news:uZGQ$YYuDHA.2368@.TK2MSFTNGP09.phx.gbl...
> Hi SQL Gurus,
> Using Sql2000, I have a table to maintain stock availibility, the
> requirement is qty_in_orders must be <= qty_on_hand, so I use CHECK
> constraint like below :
> CREATE TABLE StockAvailibility
> (prod_code CHAR(5) NOT NULL PRIMARY KEY,
> qty_on_hand INTEGER NOT NULL,
> qty_in_orders INTEGER NOT NULL,
> CHECK (qty_on_hand >= qty_in_orders));
> The problem is : user need more flexible approach, they want to decide at
> initial implementation / runtime where they need this constraint, there is a
> parameter table to store this setting.
> CREATE TABLE App_Parameter
> (Check_Stock bit);
> The above CHECK constraint should only be run if App_Parameter.Check_Stock => 1.
> How can I do this ?
> TIA,
> Krist
>
>
>|||Tibor,
Did you intend to give an example'
--
HTH,
SriSamp
Please reply to the whole group only!
http://www32.brinkster.com/srisamp
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:OIZOqdYuDHA.1740@.TK2MSFTNGP12.phx.gbl...
> You could possibly use a UDF which returns 0 or 1 and which checks against
the other table. Watch
> out, though, that if you don't refer to the column in the check
constraint, then the optimizer might
> not deem is necessary to validate the CHECK constraint. This can happen
when you have CHECK
> constraint which uses UDF can work against other tables. I don't think
that it will be a problem in
> your case, though. You could have something like:
>
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "tristant" <krislioe@.cbn.net.id> wrote in message
news:uZGQ$YYuDHA.2368@.TK2MSFTNGP09.phx.gbl...
> > Hi SQL Gurus,
> > Using Sql2000, I have a table to maintain stock availibility, the
> > requirement is qty_in_orders must be <= qty_on_hand, so I use CHECK
> > constraint like below :
> >
> > CREATE TABLE StockAvailibility
> > (prod_code CHAR(5) NOT NULL PRIMARY KEY,
> > qty_on_hand INTEGER NOT NULL,
> > qty_in_orders INTEGER NOT NULL,
> > CHECK (qty_on_hand >= qty_in_orders));
> >
> > The problem is : user need more flexible approach, they want to decide
at
> > initial implementation / runtime where they need this constraint, there
is a
> > parameter table to store this setting.
> > CREATE TABLE App_Parameter
> > (Check_Stock bit);
> >
> > The above CHECK constraint should only be run if
App_Parameter.Check_Stock => > 1.
> > How can I do this ?
> >
> > TIA,
> > Krist
> >
> >
> >
> >
> >
>|||I guess I did, but the hunger overwhelmed me and I went for lunch ;-). Below is a very stripped down
to bare essentials example:
create table t(c1 bit)
GO
create function f() returns bit as
begin
RETURN (SELECT TOP 1 c1 FROM dbo.t)
end
GO
Create table t1(c1 int)
GO
ALTER TABLE t1 ADD CONSTRAINT x CHECK(dbo.f() = 0 OR (dbo.f() = 1 AND c1 < 10))
GO
INSERT t values(0) --Means do not check
INSERT t1 values(10)
GO
UPDATE t SET c1 = 1 --Means check
INSERT t1 values(10) --Fails
UPDATE t1 SET c1 = 11 --Also fails
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"SriSamp" <ssampath@.sct.co.in> wrote in message news:%23$o2JsYuDHA.2308@.TK2MSFTNGP11.phx.gbl...
> Tibor,
> Did you intend to give an example'
> --
> HTH,
> SriSamp
> Please reply to the whole group only!
> http://www32.brinkster.com/srisamp
> "Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
> wrote in message news:OIZOqdYuDHA.1740@.TK2MSFTNGP12.phx.gbl...
> > You could possibly use a UDF which returns 0 or 1 and which checks against
> the other table. Watch
> > out, though, that if you don't refer to the column in the check
> constraint, then the optimizer might
> > not deem is necessary to validate the CHECK constraint. This can happen
> when you have CHECK
> > constraint which uses UDF can work against other tables. I don't think
> that it will be a problem in
> > your case, though. You could have something like:
> >
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > Archive at:
> http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
> >
> >
> > "tristant" <krislioe@.cbn.net.id> wrote in message
> news:uZGQ$YYuDHA.2368@.TK2MSFTNGP09.phx.gbl...
> > > Hi SQL Gurus,
> > > Using Sql2000, I have a table to maintain stock availibility, the
> > > requirement is qty_in_orders must be <= qty_on_hand, so I use CHECK
> > > constraint like below :
> > >
> > > CREATE TABLE StockAvailibility
> > > (prod_code CHAR(5) NOT NULL PRIMARY KEY,
> > > qty_on_hand INTEGER NOT NULL,
> > > qty_in_orders INTEGER NOT NULL,
> > > CHECK (qty_on_hand >= qty_in_orders));
> > >
> > > The problem is : user need more flexible approach, they want to decide
> at
> > > initial implementation / runtime where they need this constraint, there
> is a
> > > parameter table to store this setting.
> > > CREATE TABLE App_Parameter
> > > (Check_Stock bit);
> > >
> > > The above CHECK constraint should only be run if
> App_Parameter.Check_Stock => > > 1.
> > > How can I do this ?
> > >
> > > TIA,
> > > Krist
> > >
> > >
> > >
> > >
> > >
> >
> >
>