Guys:
Im new in MS SQL and I have little experienco on IBM DB2. I want to run a simple select query on a table, but I want to do it automatically... What do you recommend?? Where I can get information about OSQL or ISQL usage??'
Best regards,What do you mean 'automatically'? You can create stored procedure and run it from Quiry Analyzer by name. You can define parameters for selection criteria. Go to Online Help or Transact SQL help in Query Analyzer.|||for example in Unix you have the cron option. Means that I create the *.sql script and I schedulle it to run at certain time|||You can use SQL Server Agent.
Good luck.|||Go to Job Scheduling in Tools, Enterprise Manager. Use Create Job Wizard. Good luck.|||by the way, the query I use is very simple, select * from MEMBERS where MEM_ENTERED between '2002-05-06 00:00:00' and '2002-05-06 23:59:59'
I need to use change the date everyday. It is posible or exist the value = current date / current time in MS SQL to avoid changind date/ time everyday..
Regards|||Try this:
SELECT * from MEMBERS
where convert(char(10),mem_entered, 101)
= convert(char(10),getdate(),101)
You retrieve all the records entered for the day.
Good luck|||Thanks It works.
Just one question more. With that query I can get data for the current date. How I could change it to get for the previous day ??
In IBM DB2 I just made the date variable equal to current date - 1 day.
I will appreciate it|||Use getdate()-1 instead of getdate()- current date|||Thanks !!
It works. I will put it as schedulled job.|||I schedulled the job. But How I see the results?? Does it sends it to a log file??|||jeremas, is your goal is to run a sql script based on a cron job and dump the results to a text file?|||Thanks. I already found the way to run the query, schedule it and sending the results to a txt file. It was using the SQL Server Agent and job scheduling and properties.
Regards,
Showing posts with label db2. Show all posts
Showing posts with label db2. Show all posts
Wednesday, March 7, 2012
OSQL didnt like rookies
Sory for fullish question,but i'm coming from DB2 and Oracle world,and not SQL world.
How I can understand,OSQL utility is command-line utility in SQL server.So,I tried to start it,but it failed with error:
Login failed for user 'Administrator'. Reason: Not associated with a trusted SQL Server connection.
There is some properties for my sqlserver:
Authentication is "Windows only".User Administrator is admin on machine.In Windows services,there is one servis ( started) and logon for that service is Administrator.In fact,my SQL server works fine,because other GUIs works ok.
SQLSERVERNAME=hostname=navtest.
I tried to logon by entering in cmd this
osql -S NAVTEST
but every time I see error :
Login failed for user 'Administrator'. Reason: Not associated with a trusted SQL Server connection.
What i am doing wrong?
Every help will be greatJust because the sql service runs under the Administrator's account doesn't meen the Administrator can log onto the SQL Server.
By default, the Microsoft SQL Server setup creates the "BUILTIN\Administrators" login, which gives any account in the Local Administrators group system administrator (sa) privileges. Most people delete this account, could be the problem you are facing.
You can add the local Admin account back and grant that account sa privileges.|||Thanks,Paul!
I entered osql -s <servername> -E and it works!
Now,I tried to enter some commands,but I don't know how to end it.
I tried this:
1> select * from northwind......
2>
3> /
4>
Now,how You say to SQLSERVER execute commands?
Thanks a lot,Zvonimir|||hum... when you tried the -E what userid had you logged in with?
go terminates a block of commands.|||I find that switch -E by searching this forum...
And GO really works!!!
Thanks,Zvonimir|||Could have also found it by looking in Books Online. You can also change the command terminator with the -c switch.
btw, what userid were you using when you had success with the -E switch, Administrator?|||-E switch explicitly specifies your intent to log on using trusted connection. The default behavior for OSQL is to use Standard SQL Server Security. That's why Z was getting his(/her) error at the beginning. With -E switch the logon succeeded using security context of the currently logged on user, - Administrator.
How I can understand,OSQL utility is command-line utility in SQL server.So,I tried to start it,but it failed with error:
Login failed for user 'Administrator'. Reason: Not associated with a trusted SQL Server connection.
There is some properties for my sqlserver:
Authentication is "Windows only".User Administrator is admin on machine.In Windows services,there is one servis ( started) and logon for that service is Administrator.In fact,my SQL server works fine,because other GUIs works ok.
SQLSERVERNAME=hostname=navtest.
I tried to logon by entering in cmd this
osql -S NAVTEST
but every time I see error :
Login failed for user 'Administrator'. Reason: Not associated with a trusted SQL Server connection.
What i am doing wrong?
Every help will be greatJust because the sql service runs under the Administrator's account doesn't meen the Administrator can log onto the SQL Server.
By default, the Microsoft SQL Server setup creates the "BUILTIN\Administrators" login, which gives any account in the Local Administrators group system administrator (sa) privileges. Most people delete this account, could be the problem you are facing.
You can add the local Admin account back and grant that account sa privileges.|||Thanks,Paul!
I entered osql -s <servername> -E and it works!
Now,I tried to enter some commands,but I don't know how to end it.
I tried this:
1> select * from northwind......
2>
3> /
4>
Now,how You say to SQLSERVER execute commands?
Thanks a lot,Zvonimir|||hum... when you tried the -E what userid had you logged in with?
go terminates a block of commands.|||I find that switch -E by searching this forum...
And GO really works!!!
Thanks,Zvonimir|||Could have also found it by looking in Books Online. You can also change the command terminator with the -c switch.
btw, what userid were you using when you had success with the -E switch, Administrator?|||-E switch explicitly specifies your intent to log on using trusted connection. The default behavior for OSQL is to use Standard SQL Server Security. That's why Z was getting his(/her) error at the beginning. With -E switch the logon succeeded using security context of the currently logged on user, - Administrator.
Subscribe to:
Posts (Atom)