|
Hi,
After the report is created by the wizard:
- Select from menu Report / Report parameters
- Add a string parameter
- Right click on the title and select Expression
- you can see the static text in the expression, replace it with the parameter
- just before launching the report, deliver the value for the parameter
Hope this helps,
Mika
|
|
|
|
|
I’m creating a SQL script for an installation package that I’m working on. I want to parameterize the database creation process. Wants to be able to set the database name in a variable, and have the SQL script use that variable to create the database and the necessary tables.
So far … this part works to create the database
USE [master]
DECLARE @DBName varchar(60)
DECLARE @DBDir varchar(100)
DECLARE @SQL varchar(MAX)
SET @DBName = N'Test'
SET @DBDir = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\'
SET @SQL = N'CREATE DATABASE ' + @DBName + ' ON PRIMARY
( NAME = "' + @DBName + '",
FILENAME = "'+@DBDir + @DBName + '.mdf" ,
SIZE = 4048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = "' + @DBName + '-01_log",
FILENAME = "'+@DBDir + @DBName + '_log.ldf" ,
SIZE = 4096KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)'
EXEC (@SQL)
EXEC dbo.sp_dbcmptlevel @dbname=@DBName, @new_cmptlevel=90
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC (@DBName + '.[dbo].[sp_fulltext_database] @action = "enable"')
End
However, I can’t seem to switch to the database in script, and create the tables in it
I’ve tried -> EXEC ('USE ' + @DBName)
And also -> USE @DBName
Could you help me please ? Thank you for your time
Cecil L. Phillip
|
|
|
|
|
When you execute Exec('User' + @DBName), it is actually working. Since the exec syntax opens a new connection, your not retaining the new database in the connection your script in on. Your going to have to use 3 point qualifying names, or make a @Sql like:
Set @sql = 'Use ' + @DBName
+ ' --Do Something'
Then you'll probably run into errors about objects that must be ran first in the batch (stored procedures, for example), which "GO" will not fix because that is not a real sql syntax.
|
|
|
|
|
how would i use 3 point qualifying names and the @DBName with a create table statement or an insert ? Could you give an example ?
|
|
|
|
|
Set @Sql = 'Create Table ' + @DbName + '.dbo.TestTable '
+ '( col1 int )'
Exec (@sql)
"3 point qualifying names" is Database.Schema.Table .
|
|
|
|
|
gotcha ...
I already generated the scripts to create the tables, populate them, and create the other db objects and its a lil over 5000 lines of sql code.
I guess there is not way to maintain the current connection and change the current database huh ... hhmmm
Thank you tho.
|
|
|
|
|
|
Another point of view in creating an installation that might be useful for you.
If you create an initial database (in your own server) including all the necessary tables, views, stored procs etc. you can then:
- detach the database
- copy the data files to another location
- attach the database
After this you have a copy of the initial situation. What you can do with this is, that you can copy the files to another server (where you are installing your database) and again attach it in that sql server. This way you actually don't have to actually create any database or table creation script, simply *put* the database where you want it to be and attach it.
What you must do is to take care of:
- login creation
- user creation
- backup arrangement
- other feature used that are not stored in your database
For further info, take a look at sp_detach_db and CREATE DATABASE ... FOR ATTACH
Mika
|
|
|
|
|
What I find horrifying is that you allow the user to set the database name!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i thought that was dumb too, but thats the process that the boss wants to follow. take in mind that we only develop internal applications. The users installing the app are actually the admins in the server room
|
|
|
|
|
hi everybody
we developed windows application(c# + Linq),we have to create setup file for our application.How can i Deploy our application database along with our setup file.Please help me.
Thanks&Regards,
vishnu.
|
|
|
|
|
Using Visual studio you'll want to add a Setup and Deployment project to your solution.
Add new project -> other project types -> setup and deployment
Very Good Example Here !!
|
|
|
|
|
How do i create a "VIEW" in SQL in MS-ACCESS Databases ?
Help!
|
|
|
|
|
Ranojay wrote: How do i create a "VIEW" in SQL in MS-ACCESS Databases ?
Help!
They are in the "Queries" tab when you open the database within MS Access.
|
|
|
|
|
Sorry friends!!!!!!
The Microsoft Jet database engine does not support the use of CREATE VIEW, or any of the DDL statements, with non-Microsoft Jet database engine databases.
|
|
|
|
|
On my Vista dev machine, I've now twice come in to work in the morning to find my MSSQL service not running. This last time, the only logged event is the following, at 03:02:11 AM today:
SQL Server is terminating in response to a 'stop' request from Service Control Manager. This is an informational message only. No user action is required.
No updates are logged for today. How can I determine the source of the stop request
|
|
|
|
|
Most likely your techs are applying service patches and rebooting. Check your security log form the event log. See if you see them login at the time of the restart.
Also check if the service is automatic startup.
|
|
|
|
|
|
techs = network admins, you know hamster trainers!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Friend!
i've faced a problem.
Suppose, i have 10 records in a table.i want only the 2nd 0r 3rd position record. how can i achieve it?
thanks.......
|
|
|
|
|
This is a quick and dirty script I knocked up to illustrate one method of pulling out the second and third record.
There are more elegant solutions.
select top 1 itemnumber into #a from stocktable
order by itemnumber
select top 3 itemnumber into #b from stocktable
order by itemnumber
select #b.itemnumber from #b
left join #a
on #b.itemnumber = #a.itemnumber
where #a.itemnumber is null
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
More 1 votes please
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
Create Table #r
(
id --Identity column. Use your SQL databas's syntax here.
--For example, SQL Server is Identity(1,1).
...--Columns in the table
)
Insert #r(...--Columns in table)
Select *
From YourTable
Order By YourColumn
Select *
From #r
Where id in (2,3)
What that does is creates a new table with the same build of YourTable with an added identity column. It inserts the records and orders it, an important step is to order it or you'll may get different rows each time you run. Change the 2,3 in the in statement to get any row number you want.
|
|
|
|
|
Well ... if you are using SQL 2005 ... I think this is what you are looking for
CREATE TABLE #T (id INT IDENTITY(1,1), aField NVARCHAR(10) ) ;
INSERT INTO #T (aField) SELECT 'one' ;
INSERT INTO #T (aField) SELECT 'two' ;
INSERT INTO #T (aField) SELECT 'three' ;
INSERT INTO #T (aField) SELECT 'four' ;
INSERT INTO #T (aField) SELECT 'five' ;
INSERT INTO #T (aField) SELECT 'six' ;
INSERT INTO #T (aField) SELECT 'seven' ;
SELECT * FROM #T ORDER BY aField DESC
;WITH myTable AS (
SELECT
ROW_NUMBER() OVER( ORDER BY aField DESC ) AS RowNo
, id
, aField
FROM #T
)
SELECT *
FROM myTable
WHERE RowNo IN ( 2 , 4 ) ;
DROP TABLE #T ;
Please... SAVE my time by rating the posts that you read!
There are 10 kinds of people in the world: those who understand binary and those who don't.
modified on Friday, July 25, 2008 8:38 AM
|
|
|
|
|
This is what I would use in SQL 2000 :
CREATE TABLE #T (id INT IDENTITY(1,1), aField NVARCHAR(10) ) ;
INSERT INTO #T (aField) SELECT 'one' ;
INSERT INTO #T (aField) SELECT 'two' ;
INSERT INTO #T (aField) SELECT 'three' ;
INSERT INTO #T (aField) SELECT 'four' ;
INSERT INTO #T (aField) SELECT 'five' ;
INSERT INTO #T (aField) SELECT 'six' ;
INSERT INTO #T (aField) SELECT 'seven' ;
SELECT IDENTITY(INT, 1 , 1) AS RowNo, 0+id AS id, aField
INTO #Z
FROM #T
ORDER BY aField DESC
SELECT * FROM #Z
SELECT * FROM #Z WHERE RowNo IN ( 2 , 4 ) ;
DROP TABLE #T ;
DROP TABLE #Z ;
Please... SAVE my time by rating the posts that you read!
There are 10 kinds of people in the world: those who understand binary and those who don't.
|
|
|
|