Showing posts with label named. Show all posts
Showing posts with label named. Show all posts

Tuesday, March 27, 2012

Create a Trigger to run a Stored Procedure

I want to create a Trigger that will run once a day at a set time.

This trigger would actually run a Stored Procedure named say "spAppData".

This SP will in turn run and delete the entire tables data, and re-insert data into a table we'll call APPS.

Would anyone know how to help me get started on creating a Trigger with the info I've provided?

Thank you,

NBK

To schedule an action, you want a SQL Agent Job to execute your stored procedure at the determined time.

If you are using SQL Express (which does NOT include SQL Agent), you can use a combination of a Windows Scheduler task, SQLCmd.exe, and a Stored Procedure

|||

Thank you Arnie. That's just the direction I needed.

Wallace

|||can you please give more details on this.
i have same requrement.
thanks in advance

Thursday, March 22, 2012

Create a Named Instance on top of a Default Instance

Hi

I've never had to do this, but when I downloaded the Web Workflow Approvals Starter Kit, it requested that I install the database into a User Instance of .\SQLEXPRESS.

Now the problem is, I've installed it onto a default instance, so I was wondering whether you can create a named instance on top of a default instance... and if so, how would you do that?

Cheers

Chris

hi Chris,

you can not create one as you intend, but you can install an additional named instance for that.. or, you can modify the connection strings in the application code to connect to

Data Source=(Local); .....; User Instance=true;

instead of

Data Source=(Local)\SQLExpress; .....; User Instance=true;

regards

|||Hi Andrea

Thanks for the tip... I always wondered what user instances were for...

Now I just have to uninstall & reinstall SQL and enable it.

Cheers

Chris
sql

Tuesday, March 20, 2012

Create 2 publications for same table

Hi

I created a DB named 'TestDB' and created a table called Users. This user table having 3 columns (Uname and pwd,version).

I need to create two publication for this user table.

1) Create a publication using all columns.

2) create a publication using Uname and pwd (not version column).

I am using Merge publication.

When I create first publication (any one - all 3 columns or any 2 coulmns) it create successfully.

When I create second publication it throws error. The details are below.

TITLE: New Publication Wizard

SQL Server Management Studio could not create article 'Users'.


ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

An article with a different subscriber_upload_options value already exists for object '[dbo].[Users]'.
Changed database context to 'TestDB'. (Microsoft SQL Server, Error: 20053)

How can i create the second publication? Is it possible? If yes, please give me the steps.

Thanks

Hi

Got the solution. Solved the problem.

The problem was when i create the second publication I changed the article synchronization direction. thats why it throws the error. After givig the same article synchronization direction it is working.

Create @tablename gives syntax error

I am trying to create a table named "salesfacts" as follows:
declare @.tname1 as char(30)
set @.tname1 = 'SalesFacts'
CREATE TABLE @.tname1 ([cuid] [char](15)...
and get an error : Incorrect syntax near '@.tname1' ...
The error is related to the variable name - and not to what follows it, i.e.
'([cuid ...', as I could prove.
Only "Create table salesfacts ... " gives no error.
How can I use a variable name here instead of hard-coding the table name?
TIA> How can I use a variable name here instead of hard-coding the table name?
You'll need to build the desired SQL statement as a string and then execute
it dynamically using EXECUTE or sp_executesql. See Erland's thorough
article on the subject: http://www.sommarskog.se/dynamic_sql.html
Hope this helps.
Dan Guzman
SQL Server MVP
"PeterK" <invalid@.verizon.net> wrote in message
news:OZOGuLf0FHA.2064@.TK2MSFTNGP09.phx.gbl...
>I am trying to create a table named "salesfacts" as follows:
> declare @.tname1 as char(30)
> set @.tname1 = 'SalesFacts'
> CREATE TABLE @.tname1 ([cuid] [char](15)...
> and get an error : Incorrect syntax near '@.tname1' ...
> The error is related to the variable name - and not to what follows it,
> i.e. '([cuid ...', as I could prove.
> Only "Create table salesfacts ... " gives no error.
> How can I use a variable name here instead of hard-coding the table name?
> TIA
>
>|||"PeterK" <invalid@.verizon.net> wrote in message
news:OZOGuLf0FHA.2064@.TK2MSFTNGP09.phx.gbl...
>I am trying to create a table named "salesfacts" as follows:
> declare @.tname1 as char(30)
> set @.tname1 = 'SalesFacts'
> CREATE TABLE @.tname1 ([cuid] [char](15)...
> and get an error : Incorrect syntax near '@.tname1' ...
> The error is related to the variable name - and not to what follows it,
> i.e. '([cuid ...', as I could prove.
> Only "Create table salesfacts ... " gives no error.
> How can I use a variable name here instead of hard-coding the table name?
> TIA
>
>
You can't parameterize table names like that. But why would you want to in
this instance?
CREATE TABLE SalesFacts ([cuid] [char](15)...
David Portas
SQL Server MVP
--